Пример #1
0
function ewiki_edit_form_append_updFormat($id, $data, $action)
{
    global $ewiki_ring;
    if (!ewiki_auth_perm_liveuser($id, $data, 'manage', $ewiki_ring, 0)) {
        return '';
    }
    return ' &nbsp; <a href="' . ewiki_script('updformatheader', $id) . '">' . ewiki_t("UPDHEADERFORMAT") . '</a>';
}
Пример #2
0
/**
 * iterate over posted form data and extract selected liveuser rights to associate
 * with view and edit permissions for the current ewiki page id.
 *
 * @param array save associative array of ewiki form data
 */
function ewiki_edit_save_liveuser_manage(&$save)
{
    global $liveuserBaseRings, $liveuserDefaultPerms;
    // determine what form data is available to be processed
    $handleView = isset($_REQUEST['liveuserPermsView']) && is_array($_REQUEST['liveuserPermsView']);
    $handleEdit = isset($_REQUEST['liveuserPermsEdit']) && is_array($_REQUEST['liveuserPermsEdit']);
    $ewiki_ring = false;
    // set default rights for new pages
    if ($save['version'] == 1) {
        ewiki_liveuser_setdefault_rights($save);
    }
    // if not authorized to manage this page or form data is unavailable quit out.
    if (!ewiki_auth_perm_liveuser($save['id'], $save, 'manage', $ewiki_ring, 0) || !($handleView || $handleEdit)) {
        return;
    }
    // fetch the set of public permissions
    $rightOptions = liveuser_perm_getPublicPerms();
    /*
     * clear database of all records for public field options for rings levels
     * below edit or view. the minimum removal level (edit or view) will be determined
     * based on whether form data for edit permissions was submitted, or just
     * form data for view.
     */
    if ($handleView || $handleEdit) {
        foreach ($rightOptions as $right_id => $name) {
            liveuser_removePerm($save['id'], $right_id, $handleEdit ? $liveuserBaseRings['edit'] : $liveuserBaseRings['view']);
        }
    }
    if ($handleView) {
        foreach ($_REQUEST['liveuserPermsView'] as $right_id) {
            if (array_key_exists($right_id, $rightOptions)) {
                liveuser_addPerm($save['id'], $liveuserBaseRings['view'], $right_id, true);
            }
        }
    }
    if ($handleEdit) {
        foreach ($_REQUEST['liveuserPermsEdit'] as $right_id) {
            if (array_key_exists($right_id, $rightOptions)) {
                liveuser_addPerm($save['id'], $liveuserBaseRings['edit'], $right_id, true);
            }
        }
    }
}