示例#1
0
文件: albums.php 项目: shifter/ospap2
    $objAlbum->save();
    header('Location: index.php?action=albums');
}
if ($strSubAction == 'move') {
    if (!$objAlbum->canEdit($objUser)) {
        throw new Exception('exception_accessdenied');
    }
    /* Set the breadcrumbs and title. */
    $objBreadcrumbs->add('Albums', 'index.php?action=albums');
    $objAlbum->addBreadcrumbs($objBreadcrumbs, false);
    $objBreadcrumbs->add('Move', 'index.php?action=albums&subaction=move');
    $objTemplate->setText('PAGETITLE', "Moving an Album");
    print "<form action='index.php' method='get'>";
    print "<input type='hidden' name='action' value='albums'>";
    print "<input type='hidden' name='subaction' value='move2'>";
    print $objAlbum->getHiddenField('id');
    print "Move the album to: " . $objAlbum->getCombo('album_id', clsDB::getOptionsFromList($objAlbum->getPotentialParents($objUser), 'name', 'id', "[no parent]")) . "<br>";
    print $objAlbum->getSubmit('Move');
    print "</form>";
}
if ($strSubAction == 'move2') {
    if (!$objAlbum->canEdit($objUser)) {
        throw new Exception('exception_accessdenied');
    }
    $objAlbum->getFromRequest();
    $objParent = new clsAlbum($objAlbum->get('album_id'));
    if (!$objParent->canCreateSubalbum($objUser)) {
        throw new Exception('exception_accessdenied');
    }
    /* TODO: Make sure albums can't be moved to their own children. */
    $objAlbum->save();