Exemplo n.º 1
0
function group_content_edit(&$pObject, &$pParamHash)
{
    global $gBitSystem, $gBitSmarty, $gBitUser;
    $errors = NULL;
    if ($gBitSystem->isPackageActive('group') && $pObject->getContentType() != BITGROUP_CONTENT_TYPE_GUID) {
        $connect_group_content_id = NULL;
        // when creating new content via a group we pass the group content id to the edit form
        if (!empty($_REQUEST['connect_group_content_id'])) {
            $connect_group_content_id = $_REQUEST['connect_group_content_id'];
        } elseif ($pObject->isValid()) {
            /* when content is already assigned to a group we load up the first one into the form
            		   this is to help content types like gmap which may have subcontent edit forms ajaxed in and need the group id
            		   to keep the mappings of sub related content consistant. 
            		   we only bother for the first group we find since we don't care to obsess about this but mostly want 
            		   ensure this is right for groups that are asserting administrative control
            		 */
            $listHash['mapped_content_id'] = $pObject->mContentId;
            $listHash['offset'] = 0;
            $group = new BitGroup();
            $groups = $group->getList($listHash);
            if (count($groups) == 1) {
                $connect_group_content_id = $groups[0]['content_id'];
            }
        }
        if (!empty($connect_group_content_id)) {
            $group2 = new BitGroup(NULL, $connect_group_content_id);
            $group2->load();
            $group2->verifyLinkContentPermission($pObject);
            $group2->setGroupStyle();
            $gBitSmarty->assign("connect_group_content_id", $group2->mContentId);
            // make data available to smarty as controlling group info for theming - similarly set in lookup_group_inc
            $gBitSmarty->assign_by_ref('controlGroupInfo', $group2->mInfo);
            // check if editing is shared
            if (!$pObject->isValid()) {
                // if the content is new and registered users can edit we assume its wiki like and check the box by default
                $groupId = 3;
                $assignedPerms[$groupId] = $gBitUser->getGroupPermissions(array('group_id' => $groupId));
            } else {
                $groupId = $group2->mGroupId;
                $assignedPerms = $pObject->getContentPermissionsList();
            }
            if (!empty($assignedPerms[$groupId][$pObject->mUpdateContentPerm])) {
                $gBitSmarty->assign('groupUpdateShared', TRUE);
            }
        } elseif ($gBitSystem->isFeatureActive('group_map_required') && !($gBitUser->isAdmin() || $pObject->hasUserPermission('p_group_edit_unmapped'))) {
            $gBitSystem->fatalError(tra("You do not have permission to create or edit content outside of groups."));
        }
    }
}
Exemplo n.º 2
0
        $gBitSystem->fatalError(tra('Invalid invitation code! Please check the link you were emailed, and that you have copy-pasted it correctly.'));
    }
}
// Now check permissions to access this page
$gContent->verifyViewPermission();
// verify this group is public or the user is a member
if ((empty($gContent->mInfo['view_content_public']) || $gContent->mInfo['view_content_public'] != "y") && !$gBitUser->isInGroup($gContent->mGroupId)) {
    $gBitSystem->fatalError(tra('This is not a public group, you must be invited to join.'));
}
// make sure the user is registered
if (!$gBitUser->isRegistered()) {
    // fatal out ot login/register page
    $gBitSystem->fatalPermission(NULL);
}
// if it has a custom theme lets theme it
$gContent->setGroupStyle();
// Load a users pending moderation if it exists
$pendingModeration = NULL;
if ($gBitSystem->isPackageActive('moderation')) {
    global $gModerationSystem;
    $listHash = array('content_id' => $gContent->mContentId, 'source_user_id' => $gBitUser->mUserId, 'package' => 'group', 'type' => 'join', 'status' => MODERATION_PENDING);
    $pendingModeration = $gModerationSystem->getList($listHash);
    $gBitSmarty->assign('joinModeration', $pendingModeration);
}
// if the user is already in the group
if ($gBitUser->isInGroup($gContent->mGroupId)) {
    // user is changing their preferences
    if (!empty($_REQUEST['save_prefs']) && !empty($_REQUEST['notice'])) {
        if ($gContent->storeUserEmailPref($_REQUEST['notice'])) {
            $gBitSmarty->assign("successMsg", "Email Preference Updated");
        }