示例#1
0
function pathos_core_incrementLocationReference($loc, $section)
{
    global $db;
    $newLocRef = $db->selectObject("locationref", "module='" . $loc->mod . "' AND source='" . $loc->src . "' AND internal='" . $loc->int . "'");
    $is_new = false;
    // For the is_original sectionref attribute
    if ($newLocRef != null) {
        // Pulled an existing source.  Update refcount
        $newLocRef->refcount += 1;
        $db->updateObject($newLocRef, "locationref", "module='" . $loc->mod . "' AND source='" . $loc->src . "' AND internal='" . $loc->int . "'");
    } else {
        $is_new = true;
        // New source.  Populate reference
        $newLocRef->module = $loc->mod;
        $newLocRef->source = $loc->src;
        $newLocRef->internal = $loc->int;
        $newLocRef->refcount = 1;
        $db->insertObject($newLocRef, "locationref");
        // Go ahead and assign permissions on contained module.
        $perms = call_user_func(array($loc->mod, "permissions"));
        global $user;
        foreach (array_keys($perms) as $perm) {
            pathos_permissions_grant($user, $perm, $loc);
        }
        pathos_permissions_triggerSingleRefresh($user);
    }
    $newSecRef = $db->selectObject("sectionref", "module='" . $loc->mod . "' AND source='" . $loc->src . "' AND internal='" . $loc->int . "' AND section={$section}");
    if ($newSecRef != null) {
        // Pulled an existing source for this section.  Update refcount
        $newSecRef->refcount += 1;
        $db->updateObject($newSecRef, "sectionref", "module='" . $loc->mod . "' AND source='" . $loc->src . "' AND internal='" . $loc->int . "' AND section={$section}");
    } else {
        // New source for this section.  Populate reference
        $newSecRef->module = $loc->mod;
        $newSecRef->source = $loc->src;
        $newSecRef->internal = $loc->int;
        $newSecRef->section = $section;
        $newSecRef->refcount = 1;
        $newSecRef->is_original = $is_new ? 1 : 0;
        $db->insertObject($newSecRef, "sectionref");
    }
}
        $directory = 'files/imagegallerymodule/' . $loc->src . '/gallery' . $id;
        #.'/.thumbs';
        if (!file_exists(BASE . $directory)) {
            $err = pathos_files_makeDirectory($directory);
            if ($err != SYS_FILES_SUCCESS) {
                echo '<div class="error">';
                if ($err == SYS_FILES_FOUNDFILE) {
                    echo TR_FILEMANAGER_FILEFOUNDINPATH;
                } else {
                    if ($err == SYS_FILES_NOTWRITABLE) {
                        echo TR_FILEMANAGER_CANTMKDIR;
                    } else {
                        echo TR_FILEMANAGER_UNKNOWNERROR;
                    }
                }
                echo '</div>';
                $db->delete('imagegallery_gallery', 'id=' . $id);
                return;
            }
        }
        // Assign permissions -- need to create an internal loc
        $iloc = pathos_core_makeLocation($loc->mod, $loc->src, $id);
        foreach (array_keys(imagegallerymodule::permissions($id)) as $perm) {
            pathos_permissions_grant($user, $perm, $iloc);
        }
        pathos_permissions_triggerSingleRefresh($user);
    }
    pathos_flow_redirect();
} else {
    echo SITE_403_HTML;
}