echo "----TESTING----\n\n\n";
}
// Get list of uids of members in origin group.
$results = db_query("SELECT uid FROM og_uid WHERE nid = %d", $origin_group);
$origin_uids = array();
while ($data = db_fetch_array($results)) {
    $origin_uids[] = $data['uid'];
}
echo "Moving uids to new group\n";
foreach ($origin_uids as $uid) {
    if (!$test) {
        og_save_subscription($dest_group, $uid, array("is_active" => 1));
    }
    echo "Added uid " . $uid . " to group: " . $dest_name . " from group: " . $origin_name . "\n";
}
foreach ($origin_uids as $uid) {
    if (!$test && !in_array($uid, $admins)) {
        og_delete_subscription($origin_group, $uid);
    }
    echo "Deleted uid " . $uid . " from group: " . $origin_name . "\n";
}
// Inform Group memebers of the Move.
$subject = "Moved your group subscription from " . $origin_name . " to " . $dest_name;
$body = "This message is to inform you that your group subscription in the " . $orgin_name . " group has been moved to the " . $dest_name . ". \n\n You may visit your new group at " . l($dest_name, "node/" . $dest_group);
echo $subject . "\n";
echo $body;
if (!$test) {
    foreach ($origin_uids as $uid) {
        notifications_lite_send($uid, $subject, $body);
    }
}
Esempio n. 2
0
 static function groupContact($groupID, $contactIDs, $op)
 {
     require_once 'CRM/Bridge/OG/Utils.php';
     $ogID = CRM_Bridge_OG_Utils::ogID($groupID, false);
     if (!$ogID) {
         return;
     }
     require_once 'api/v2/UFGroup.php';
     foreach ($contactIDs as $contactID) {
         $drupalID = civicrm_uf_id_get($contactID);
         if ($drupalID) {
             if ($op == 'add') {
                 og_save_subscription($ogID, $drupalID, array('is_active' => 1));
             } else {
                 og_delete_subscription($ogID, $drupalID);
             }
         }
     }
 }
Esempio n. 3
0
 /**
  * Wrapper for og_membership deletion.
  *
  * @param int $ogID
  *   Organic Group ID.
  * @param int $drupalID
  *   Drupal User ID.
  */
 public function og_membership_delete($ogID, $drupalID)
 {
     og_delete_subscription($ogID, $drupalID);
 }