function groups_moderation_callback(&$pModeration) { global $gBitUser, $gBitSystem; if ($pModeration['type'] == 'join') { if ($pModeration['status'] == MODERATION_APPROVED) { // Add the user to the group $gBitUser->addUserToGroup($pModeration['source_user_id'], $pModeration['moderator_group_id']); // Store the users notification preference if ($gBitSystem->isPackageActive('switchboard') && !empty($pModeration['data']['notice'])) { if ($pModeration['data']['notice'] == 'email' || $pModeration['data']['notice'] == 'digest') { global $gSwitchboardSystem; $gSwitchboardSystem->storeUserPref($pModeration['source_user_id'], 'group', 'message', $pModeration['content_id'], $pModeration['data']['notice']); } } } } else { if ($pModeration['type'] == 'invite') { if ($pModeration['status'] == MODERATION_APPROVED) { // Add the user to the group $group = new BitGroup(NULL, $pModeration['content_id']); $group->load(); $gBitUser->addUserToGroup($pModeration['moderator_id'], $group->mGroupId); } } else { if ($pModeration['type'] == 'add_content') { if ($pModeration['status'] == MODERATION_APPROVED) { if (!empty($pModeration['data']['map_content_id'])) { $group = new BitGroup(NULL, $pModeration['content_id']); $group->load(); $group->linkContent(array("content_id" => $pModeration['data']['map_content_id'])); } // @TODO would be nice to be able to kick an error or msg back to the moderation system } } } } return TRUE; }
function group_content_store(&$pObject, &$pParamHash) { global $gBitSystem, $gLibertySystem, $gBitUser; $errors = NULL; if ($gBitSystem->isPackageActive('group')) { //----- content to group mapping -----// if (!empty($pParamHash['connect_group_content_id'])) { $groupContent = new BitGroup(NULL, $pParamHash['connect_group_content_id']); $groupContent->load(); $groupContent->verifyLinkContentPermission($pObject); $linkHash = array("content_id" => $pParamHash['content_id'], "title" => $pParamHash['title']); if (!$groupContent->linkContent($linkHash)) { $errors = $groupContent->mErrors; } //----- end set access perms -----// /** * Assign custom view content perm on the object to be mapped based on if group is public or not * Assign custom edit contetn perm on the object to restrict access to the group for wiki like content * * @TODO This code is nearly identical to code in edit.php - may want to move into a group class method. */ $typeGuid = $pObject->mType['content_type_guid']; $contentId = $pObject->mContentId; if (!isset($gLibertySystem->mContentTypes[$typeGuid]['content_perms'])) { $gLibertySystem->mContentTypes[$typeGuid]['content_perms'] = secure_get_content_permissions($typeGuid); } if (isset($gLibertySystem->mContentTypes[$typeGuid]['content_perms']['view'])) { $viewPerm = $gLibertySystem->mContentTypes[$typeGuid]['content_perms']['view']; $updatePerm = $gLibertySystem->mContentTypes[$typeGuid]['content_perms']['update']; // foreach user group $groupsHash = array(); $allGroups = $gBitUser->getAllGroups($groupsHash); foreach ($allGroups as $groupId => $group) { $groupPerms = array_keys($group['perms']); // if group has content view perm by default and is not admin and not our group if ($groupId != 1 && $groupId != $groupContent->mGroupId && in_array($viewPerm, $groupPerms)) { if ($groupContent->mInfo['view_content_public'] != 'y') { // revoke $groupContent->storePermission($groupId, $viewPerm, TRUE, $contentId); } else { // unrevoke if revoked $groupContent->removePermission($groupId, $viewPerm, $contentId); } } // if group has content update perm by default and is not admin, not editors, and not our group if ($groupId != 1 && $groupId != 2 && $groupId != $groupContent->mGroupId && in_array($updatePerm, $groupPerms)) { // revoke to revoke wiki like editing - we never restore this $groupContent->storePermission($groupId, $updatePerm, TRUE, $contentId); } } // set custom view perm for our group if ($groupContent->mInfo['view_content_public'] != 'y') { // assign view to our group $groupContent->storePermission($groupContent->mGroupId, $viewPerm, FALSE, $contentId); } else { // remove custom view perm for our group since its not needed $groupContent->removePermission($groupContent->mGroupId, $viewPerm, $contentId); } // set custom update perm for our group for wiki like editing among group members if ($pObject->isOwner() || $pObject->hasAdminPermission()) { if (!empty($pParamHash['group_share_update']) && $pParamHash['group_share_update'] == 'y') { // assign edit to our group $groupContent->storePermission($groupContent->mGroupId, $updatePerm, FALSE, $contentId); } else { // remove custom update perm for our group if revoked $groupContent->removePermission($groupContent->mGroupId, $updatePerm, $contentId); } } } //----- end set access perms -----// } //----- end content to group mapping -----// //----- change of email address -----// // this updates the users email address if the user is subscribed to any mailing lists if (!empty($pParamHash['chgemail']) && $gBitSystem->isPackageActive('boards')) { require_once UTIL_PKG_PATH . 'mailman_lib.php'; $query = "SELECT lcp.`pref_value`\n\t\t\t\t\tFROM `" . BIT_DB_PREFIX . "liberty_content_prefs` lcp\n\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "groups_content_cnxn_map` gccm ON lcp.`content_id` = gccm.`to_content_id`\n\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "groups` g ON g.`content_id` = gccm.`group_content_id`\n\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "users_groups_map` ugm ON ugm.`group_id` = g.`group_id`\n\t\t\t\t\tWHERE lcp.`pref_name` = ? AND ugm.`user_id` = ?"; $bindVars = array('boards_mailing_list', $pObject->mUserId); $mailingLists = $pObject->mDb->getArray($query, $bindVars, 99999, 0); foreach ($mailingLists as $key => $val) { if (mailman_findmember($val['pref_value'], $pParamHash['org_email'])) { // delete and replace it mailman_remove_member($board->getPreference('boards_mailing_list'), $pParamHash['org_email']); mailman_addmember($board->getPreference('boards_mailing_list'), $pUser->getField('email')); } } } //----- end change of email address -----// } // end check group package is active return $errors; }