| 1 |
<?php |
<?php |
| 2 |
// $Id: comms.module,v 1.1.4.18 2009/09/19 06:52:07 evoltech Exp $ |
// $Id: comms.module,v 1.1.4.19 2009/09/20 00:07:22 evoltech Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 1668 |
|
|
| 1669 |
switch ($action) { |
switch ($action) { |
| 1670 |
case 'add': |
case 'add': |
| 1671 |
foreach ($term_gids as $gid => $group_name) { |
foreach ($term_gids as $igid => $group_name) { |
| 1672 |
// Make sure the group isn't already added to the list, then add |
// Make sure the group isn't already added to the list, then add |
| 1673 |
// it. |
// it. |
| 1674 |
if (!in_array($gid, $node->og_groups) === TRUE) { |
if (!in_array($igid, $node->og_groups) === TRUE) { |
| 1675 |
$node->og_groups[] = $gid; |
$node->og_groups[] = $igid; |
| 1676 |
$gids[$gid] = $group_name; |
$gids[$igid] = $group_name; |
| 1677 |
} |
} |
| 1678 |
} |
} |
| 1679 |
if (!empty($gids)) { |
if (!empty($gids)) { |
| 1680 |
og_save_ancestry($node); |
og_save_ancestry($node); |
|
$message = 'og_groups: '. implode(', ', $node->og_groups) |
|
|
."\nterm_gids: ". implode(', ', array_keys($term_gids)) ."\n"; |
|
| 1681 |
} |
} |
| 1682 |
else { |
else { |
| 1683 |
$message = t('No new groups were added.'); |
$message = t('No new groups were added.'); |
| 1690 |
$nid, $gid); |
$nid, $gid); |
| 1691 |
break; |
break; |
| 1692 |
case 'remove': |
case 'remove': |
| 1693 |
foreach ($term_gids as $gid => $group_name) { |
// @todo, broken for removing gids. |
| 1694 |
|
foreach ($term_gids as $igid => $group_name) { |
| 1695 |
// If the group is in the list, then remove it. |
// If the group is in the list, then remove it. |
| 1696 |
if ($index = array_search($gid, $node->og_groups) !== FALSE) { |
if ($index = array_search($igid, $node->og_groups) !== FALSE) { |
| 1697 |
array_splice($node->og_groups, $index, 1); |
$gids[$igid] = $group_name; |
|
$gids[$gid] = $group_name; |
|
| 1698 |
} |
} |
| 1699 |
} |
} |
| 1700 |
if (!empty($gids)) { |
if (!empty($gids)) { |
| 1701 |
|
$node->og_groups = array_values( |
| 1702 |
|
array_diff($node->og_groups, array_keys($term_gids))); |
| 1703 |
og_save_ancestry($node); |
og_save_ancestry($node); |
| 1704 |
} |
} |
| 1705 |
else { |
else { |
| 1706 |
$message = t('No groups were removed.'); |
$message .= t('No groups were removed.'); |
| 1707 |
} |
} |
| 1708 |
|
|
| 1709 |
// Unbind the term from the node. |
// Unbind the term from the node. |