Example #1
0
function delete_collection($id)
{
    $params = array(':collection_id' => $id);
    $qry = new AwlQuery('SELECT child.collection_id AS child_id FROM collection child JOIN collection parent ON (parent.dav_name = child.parent_container) WHERE parent.collection_id = :collection_id', $params);
    if ($qry->Exec('DELETE', __LINE__, __FILE__) && $qry->rows() > 0) {
        while ($row = $qry->Fetch()) {
            delete_collection($row->child_id);
        }
    }
    if ($qry->QDo("SELECT write_sync_change(collection_id, 404, caldav_data.dav_name) FROM caldav_data WHERE collection_id = :collection_id", $params) && $qry->QDo("DELETE FROM property WHERE dav_name LIKE (SELECT dav_name FROM collection WHERE collection_id = :collection_id) || '%'", $params) && $qry->QDo("DELETE FROM locks WHERE dav_name LIKE (SELECT dav_name FROM collection WHERE collection_id = :collection_id) || '%'", $params) && $qry->QDo("DELETE FROM caldav_data WHERE collection_id = :collection_id", $params) && $qry->QDo("DELETE FROM collection WHERE collection_id = :collection_id", $params)) {
        @dbg_error_log("DELETE", "DELETE (collection): User: %d, ETag: %s, Path: %s", $session->user_no, $request->etag_if_match, $request->path);
        return true;
    }
    return false;
}
            # No collections to select. Create them a new collection.
            $name = get_mycollection_name($userref);
            $usercollection = create_collection($userref, $name);
            set_user_collection($userref, $usercollection);
        }
    }
    refresh_collection_frame($usercollection);
}
$deleteempty = getvalescaped("deleteempty", "");
if ($deleteempty != "") {
    $collections = get_user_collections($userref);
    $deleted_usercoll = false;
    for ($n = 0; $n < count($collections); $n++) {
        // if count is zero and not My Collection and collection is owned by user:
        if ($collections[$n]['count'] == 0 && $collections[$n]['cant_delete'] != 1 && $collections[$n]['user'] == $userref) {
            delete_collection($collections[$n]['ref']);
            if ($collections[$n]['ref'] == $usercollection) {
                $deleted_usercoll = true;
            }
        }
    }
    # Get count of collections
    $c = get_user_collections($userref);
    # If the user has just deleted the collection they were using, select a new collection
    if ($deleted_usercoll && count($c) > 0) {
        # Select the first collection in the dropdown box.
        $usercollection = $c[0]["ref"];
        set_user_collection($userref, $usercollection);
    }
    # User has deleted their last collection? add a new one.
    if (count($c) == 0) {
// Here we will determine if we need to perform any form actions.
if (isset($_REQUEST['action'])) {
    switch ($_REQUEST['action']) {
        case 'move-delete':
            // We're either moving or deleting
            $num_items = 0;
            $action_result = array();
            if (isset($_REQUEST['delete_checked'])) {
                // Perform the delete function on the selected items
                if (isset($_REQUEST['selected'])) {
                    foreach ($_REQUEST['selected'] as $del_id) {
                        if ($level == 'pictures') {
                            $rv = delete_picture($del_id);
                        }
                        if ($level == 'collections') {
                            $rv = delete_collection($del_id);
                        }
                        if ($level == 'albums') {
                            $rv = delete_album($del_id);
                        }
                        if (isset($rv['errors'])) {
                            $output .= "\n\t" . '<p class="errors">' . $rv['errors'] . '</p>' . "\n";
                        } else {
                            $num_items++;
                        }
                    }
                    if ($num_items > 0) {
                        $text = $num_items == 1 ? plog_tr('entry') : plog_tr('entries');
                        $output .= "\n\t" . '<p class="success">' . sprintf(plog_tr('You have deleted %s successfully'), '<strong>' . $num_items . '</strong> ' . $text) . '.</p>' . "\n";
                    }
                } else {
Example #4
0
if ($modified_collection_valid_order_bys) {
    $collection_valid_order_bys = $modified_collection_valid_order_bys;
}
if (!in_array($col_order_by, $collection_valid_order_bys)) {
    $col_order_by = "created";
}
# Check the value is one of the valid values (SQL injection filter)
if (array_key_exists("find", $_POST)) {
    $offset = 0;
}
# reset page counter when posting
$name = getvalescaped("name", "");
$delete = getvalescaped("delete", "");
if ($delete != "") {
    # Delete collection
    delete_collection($delete);
    # Get count of collections
    $c = get_user_collections($userref);
    # If the user has just deleted the collection they were using, select a new collection
    if ($usercollection == $delete && count($c) > 0) {
        # Select the first collection in the dropdown box.
        $usercollection = $c[0]["ref"];
        set_user_collection($userref, $usercollection);
    }
    # User has deleted their last collection? add a new one.
    if (count($c) == 0) {
        # No collections to select. Create them a new collection.
        $name = get_mycollection_name($userref);
        $usercollection = create_collection($userref, $name);
        set_user_collection($userref, $usercollection);
    }
Example #5
0
             include 'manageCollections.php';
         }
     } else {
         $message = 'Please sign in to manage collections';
         include 'home.php';
     }
     break;
 case 'deletecollection':
     if (isset($_SESSION['user_name'])) {
         $collections = get_collections($_SESSION['user_id']);
         $collection_id = filter_input(INPUT_POST, 'collection_id', FILTER_VALIDATE_INT);
         if ($collection_id == NULL || $collection_id == false) {
             $message = 'Something went wrong, try again';
             include 'manageCollections.php';
         } else {
             $message = delete_collection($collection_id);
             if ($message == 'error') {
                 $message = 'A database error occurred';
             } elseif ($message == 'success') {
                 $message = 'Collection Deleted';
             }
             $collections = get_collections($_SESSION['user_id']);
             include 'manageCollections.php';
         }
     } else {
         $message = 'Please sign in to manage collections';
         include 'home.php';
     }
     break;
     //this case is for an ajax function - therefore it doesnt include any views
 //this case is for an ajax function - therefore it doesnt include any views
    //    'has New Version' => $hasNewVersion
    // ));
}
// DELETE
// ============================================================
// - delete file from collection
// - delete collection and all files in the collection
// ============================================================
// delete file
if ($delete_file && $file_id) {
    delete_resource($file_id);
    printJson(true);
}
// delete collection and all files in the collection
if ($delete_collection && $collection_id) {
    $delete = delete_collection($collection_id);
    printJson($delete);
}
// CREATE
// ============================================================
// - create a new collection
// ============================================================
// create a new collection
// returns id of new collection
if ($create_collection && $collection_name && $user_id) {
    $allowchanges = 1;
    $cant_delete = 0;
    $collection_name = urldecode($collection_name);
    if ($remove_unserscore) {
        $collection_name = str_replace('_', ' ', $collection_name);
    }