IMCE Gallery. Как удалить галерею или фото?

Главные вкладки

Аватар пользователя Drupan Drupan 8 июля 2008 в 23:24

Установил и как полагается - экспериментировал.
Завёл пару галерей. Закачал несколько фоток. Понравилось
Далее решил лишнюю галерею удалить.., ан нет, не удаляется.
Попробовал переименовать, не переименовывается.
Решил удалить тестовые фотки. Не могу найти удалялки.
Что делать? Кто знает, подскажите, как укротить "строптивую"?

Комментарии

Аватар пользователя dipsy dipsy 29 марта 2009 в 12:59

для удаления файлов из галереи в файле imce_gallery.module поправить:

function imce_gallery_add($user) {
        if(!is_numeric(arg(2)) && arg(1) != 'edit')
        $output = "<br/>Please fill all the fields in the form below";
        $output .= drupal_get_form('imce_gallery_form', $user);
       
    $output .= imce_edit_image_list($user);
        return $output;
}
function lambda_imce_edit_image_list($x){
    return "g_item_id=%d";
}
function imce_edit_image_list($user){
    $gid = arg(2);
    if ( $_POST["delete_items"] == "1" ){
        $keys = array_keys($_POST);
        $key_array = Array();
        foreach ($keys as $key){
            if ( strpos( $key, "del_item_" ) === 0){
                $key_array[] = (int)str_replace( "del_item_", "", $key );
            }
           
        }
        $sql = "delete from {imce_gallery_items} where "
            . (implode( " or ", array_map( "lambda_imce_edit_image_list", $key_array ) ) );
        db_query( $sql, $key_array );
    }
    if(arg(1) == 'edit' && is_numeric(arg(2))){
                $sql = "SELECT * FROM {imce_gallery}
                WHERE gid=%d AND uid=%d"
;
                $row = db_fetch_object(db_query($sql, $gid, $user->uid));
        if ($user->uid == 1 || $row->uid == $user->uid ) {
            $result = "<form method=\"POST\">
                <ul style=\"list-style-type: none;\">
                %IMAGE_LIST%
                </ul>
                <input type=\"hidden\" name=\"delete_items\" value=\"1\"/>
                <input type=\"submit\" value=\"Delete from gallery\">
            </form>"
;
            $sql = "
                select g_item_id id, g_file_name path from {imce_gallery_items}
                where gid=%d and uid=%d
            "
;
            $qRes = db_query($sql, $gid, $user->uid);
            $content = "";
            while ($img = db_fetch_object($qRes)){
                $path = "/files/u{$user->uid}/" . str_replace( ".jpg", "_0.jpg", $img->path );
                if (!file_exists($path)){
                    $path = "/files/u{$user->uid}/{$img->path}";
                }
                $row = "<li>
                <input type=\"checkbox\" name=\"del_item_{$img->id}\">
                {$img->path}                
                <img width=\"150\" src=\"{$path}\">
                </li>"
;
                $content .= $row;
            }
            $result = str_replace( "%IMAGE_LIST%", $content, $result );
           
        } else {            
            $result = "";
        }        
    }
    return $result;
}