Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
*/
if (isset($_REQUEST["submit_mult"]) && isset($_REQUEST["checked"]) && $_REQUEST["submit_mult"] == "remove_groups") {
    // Now check permissions to remove the selected groups
    $gBitSystem->verifyPermission('p_group_remove');
    if (!empty($_REQUEST['cancel'])) {
        // user cancelled - just continue on, doing nothing
    } elseif (empty($_REQUEST['confirm'])) {
        $formHash['delete'] = TRUE;
        $formHash['submit_mult'] = 'remove_groups';
        foreach ($_REQUEST["checked"] as $del) {
            $tmpPage = new BitGroup($del);
            if ($tmpPage->load() && !empty($tmpPage->mInfo['title'])) {
                $info = $tmpPage->mInfo['title'];
            } else {
                $info = $del;
            }
            $formHash['input'][] = '<input type="hidden" name="checked[]" value="' . $del . '"/>' . $info;
        }
        $gBitSystem->confirmDialog($formHash, array('warning' => tra('Are you sure you want to delete these groups?') . ' (' . tra('Count: ') . count($_REQUEST["checked"]) . ')', 'error' => tra('This cannot be undone!')));
    } else {
        foreach ($_REQUEST["checked"] as $deleteId) {
            $tmpPage = new BitGroup($deleteId);
            if (!$tmpPage->load() || !$tmpPage->expunge()) {
                array_merge($errors, array_values($tmpPage->mErrors));
            }
        }
        if (!empty($errors)) {
            $gBitSmarty->assign_by_ref('errors', $errors);
        }
    }
}
Exemplo n.º 3
0
function group_content_expunge(&$pObject, &$pParamHash)
{
    global $gBitSystem, $gBitDb;
    $errors = NULL;
    if ($gBitSystem->isPackageActive('group')) {
        $groups = $gBitDb->getArray("SELECT g.`group_id` FROM `" . BIT_DB_PREFIX . "groups` g INNER JOIN `" . BIT_DB_PREFIX . "groups_content_cnxn_map` gccm ON ( gccm.`group_content_id` = g.`content_id` ) WHERE gccm.`to_content_id` = ?", array($pObject->mContentId));
        foreach ($groups as $group) {
            $group = new BitGroup($group['group_id']);
            $group->load();
            $unlinkHash = array("content_id" => $pObject->mContentId);
            if (!$group->unlinkContent($unlinkHash)) {
                $errors = $group->mErrors;
            }
        }
    }
    return $errors;
}
Exemplo n.º 4
0
if (empty($lookupHash)) {
    $lookupHash =& $_REQUEST;
}
// if we already have a gContent, we assume someone else created it for us, and has properly loaded everything up.
if (empty($gContent) || !is_object($gContent) || !$gContent->isValid()) {
    // if someone gives us a group_name we try to find it
    if (!empty($lookupHash['group_name'])) {
        global $gBitDb;
        $lookupHash['group_id'] = $gBitDb->getOne("SELECT group_id FROM `" . BIT_DB_PREFIX . "groups` g LEFT JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON (g.`content_id` = lc.`content_id`) WHERE lc.`title` = ?", array($lookupHash['group_name']));
        if (empty($lookupHash['group_id'])) {
            $gBitSystem->fatalError(tra('No group found with the name: ') . $lookupHash['group_name']);
        }
    }
    // if group_id supplied, use that
    if (@BitBase::verifyId($lookupHash['group_id'])) {
        $gContent = new BitGroup($lookupHash['group_id']);
        // if content_id supplied, use that
    } elseif (@BitBase::verifyId($lookupHash['content_id'])) {
        $gContent = new BitGroup(NULL, $lookupHash['content_id']);
    } elseif (@BitBase::verifyId($lookupHash['group']['group_id'])) {
        $gContent = new BitGroup($lookupHash['group']['group_id']);
        // otherwise create new object
    } else {
        $gContent = new BitGroup();
    }
    $gContent->load();
    $gBitSmarty->assign_by_ref("gContent", $gContent);
    // ControlGroupInfo is for customizing layouts in other parts of the site (see BitGroup::group_content_display)
    // but we need it here too if we want to apply layout features consistently while browsing groups/ too and keep our tpls simple
    $gBitSmarty->assign_by_ref("controlGroupInfo", $gContent->mInfo);
}