Ejemplo n.º 1
0
function book_createAsset($book_id = 0, $asset_type = "html", $ref_date = null, $qualifier = null, $contents = null)
{
    /* Step 0: Validation */
    if (0 == $book_id) {
        config_setLastError('Bad book id');
        return null;
    }
    /* Step 1: Get book info from DB */
    $book = null;
    $booklist = db_booklist(null, PERM_WRITE, $book_id);
    if ($booklist) {
        $book = $booklist[$book_id];
    }
    if (null == $book) {
        config_setLastError('Book not found or insufficient permissions.');
        return null;
        // Not found or no access
    }
    /* Step 2: Call object method to create file */
    $asset = $book->createAsset($asset_type, $ref_date, $qualifier);
    if (null == $asset) {
        config_setLastError('Asset creation failed.');
        return null;
    }
    /* Step 3: If we have contents, push them now */
    if (null != $contents) {
        if (FALSE == file_put_contents($asset, $contents)) {
            /* Write failed; delete the asset and return */
            unlink($asset);
            config_setLastError('Asset contents could not be stored.');
            return null;
        }
    }
    /* Step 4: We're all good here, just return the new path */
    return $asset;
}
Ejemplo n.º 2
0
header('Content-type: text/html');
// If the skin has pre-content setup, include it here.
require_once "library/core/util-skin.php";
require_once "library/core/util-db.php";
require_once "library/core/util-auth.php";
require_once "library/core/class-book.php";
require_once "library/core/util-config.php";
skin_include("svc-edit-book-pre.php");
?>

<?php 
/* Step 1: Get current user info */
auth_validate();
$bookid = 0 + $_REQUEST['book'];
/* Step 2: Get book out of DB (if it's there) */
$booklist = db_booklist($auth_user->uid, PERM_EDIT, $bookid);
if (null != $booklist) {
    $book =& $booklist[$bookid];
    config_setParameter('edit-book-object', $book);
}
/* Step 3: Check for special book types */
if ($bookid < 1000) {
    switch ($bookid) {
        case BOOK_ID_PROFILE:
            @(include "svc-edit-book-profile.php");
            break;
        case BOOK_ID_ANNOUNCEMENTS:
            @(include "svc-edit-book-announcement.php");
            break;
        case BOOK_ID_SERMONS:
            @(include "svc-edit-book-sermon.php");
Ejemplo n.º 3
0
//  Bookshelf menu block -- retrieve the current user's
//        books and optionally start editing one.
//
// If the skin has pre-content setup, include it here.
require_once "library/core/util-skin.php";
skin_include("block-bookshelf-menu-pre.php");
?>
<div id="bookshelf-menu-container">
<?php 
// Includes
require_once "library/core/util-db.php";
// Make main shelf container
$bookShelf = new akBookshelf("bookshelf", "bookshelf-div");
$bookShelf->setTitle("Available Books");
// Retrieve list of books for current user
$booklist = db_booklist();
// NULL author means current
if (null != $booklist) {
    foreach ($booklist as $book) {
        $bookShelf->adopt($book);
    }
}
// Add divider
$book = new akBook("Tools", BOOK_TYPE_DIVIDER);
$bookShelf->adopt($book);
// Add common elements (last)
// Profile editor
$book = new akBook("Edit Profile", BOOK_TYPE_PROFILE);
$book->id = BOOK_ID_PROFILE;
$book->setHint("Edit your user profile and settings");
$bookShelf->adopt($book);