Beispiel #1
0
 } else {
     // remove custom view perm for our group since its not needed
     $gContent->removePermission($gContent->mGroupId, $gContent->mViewContentPerm);
 }
 // assign custom view perms for our group's linked content
 // we need this to get all view perms
 require_once LIBERTYSECURE_PKG_PATH . 'libertysecure_lib.php';
 // get all group linked content
 $listHash = array("connect_group_content_id" => $gContent->mContentId);
 $list = $gContent->getContentList($listHash);
 // for each content item set custom view perms
 foreach ($list as $content) {
     $typeGuid = $content['content_type_guid'];
     $contentId = $content['content_id'];
     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'];
         // foreach user group
         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 != $gContent->mGroupId && in_array($viewPerm, $groupPerms)) {
                 if ($gContent->mInfo['view_content_public'] != 'y') {
                     // revoke
                     $gContent->storePermission($groupId, $viewPerm, TRUE, $contentId);
                 } else {
                     // unrevoke if revoked
                     $gContent->removePermission($groupId, $viewPerm, $contentId);
                 }
Beispiel #2
0
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;
}