forum.coppermine-gallery.net

Support => cpg1.5.x Support => cpg1.5 miscellaneous => Topic started by: timberguy on January 15, 2012, 12:44:45 am

Title: Preventing users from inadvertantly deleting albums
Post by: timberguy on January 15, 2012, 12:44:45 am
Is there a way to remove the album delete link for users other than an admin? We've had the problem several times of users inadvertently deleting an entire album when they think they are deleting the last photo they uploaded. They see the new thumbnail of that photo on the album, and think they are deleting the photo.This can be pretty traumatic for a gallery that is used primarily for storing photos to be posted on a forum.  It happened again tonight.  I usually always have recent back up for the photos, at least within 24 hours of an incident, but restoring the photos to an album, while it may put the photos back on our forum, it does not restore the database for the gallery.

if there was just someway of screaming "YOU ARE ABOUT TO DO SOMETHING VERY STUPID" or taking the link to delete an album away, it would be great.  I appreciate any suggestions.
Title: Re: Preventing users from inadvertantly deleting albums
Post by: lurkalot on January 15, 2012, 01:35:28 am
It does give a warning that you're about to delete the Album, as per my my screengrab.  Or at least it should do.  That said, I do understand the problem, I've had a couple of my members do the same thing.
Title: Re: Preventing users from inadvertantly deleting albums
Post by: Αndré on January 17, 2012, 02:48:22 pm
Do you prefer to change the message or removing the button?
Title: Re: Preventing users from inadvertantly deleting albums
Post by: timberguy on January 17, 2012, 08:06:08 pm
My first instinct is to remove the button form anyone but an admin, but only for albums. I have edited the button text to say STOP! THIS WILL DELETE ENTIRE ALBUM!  But that makes for a pretty big button.

You would think the pop-up would be sufficient, but people are just so programed to click through stuff anymore that they screw up.  Changing the text should do it, but I wouldn't bet on it.
Title: Re: Preventing users from inadvertantly deleting albums
Post by: Αndré on January 18, 2012, 02:24:46 pm
To remove that button for regular users, copy the following code block to your theme's theme.php file:
Code: [Select]
$template_album_admin_menu_nonadmin = <<<EOT
        <div class="buttonlist align_right">
                <ul>
                        <li>
                                <a href="modifyalb.php?album={ALBUM_ID}"><span>{MODIFY}</span></a>
                        </li>
                        <li>
                                <a href="editpics.php?album={ALBUM_ID}"><span class="last">{EDIT_PICS}</span></a>
                        </li>
                </ul>
        </div>
        <div class="clearer"></div>

EOT;


Additionally, open index.php, find
Code: [Select]
function html_albummenu($id)
{
    global $template_album_admin_menu, $lang_album_admin_menu;

    static $template = '';

    if ($template == '') {
        list($timestamp, $form_token) = getFormToken();
        $params = array(
            '{CONFIRM_DELETE}' => $lang_album_admin_menu['confirm_delete'],
            '{DELETE}' => cpg_fetch_icon('delete', 1) . $lang_album_admin_menu['delete'],
            '{MODIFY}' => cpg_fetch_icon('modifyalb', 1) . $lang_album_admin_menu['modify'],
            '{EDIT_PICS}' => cpg_fetch_icon('edit', 1) . $lang_album_admin_menu['edit_pics'],
            '{FORM_TOKEN}' => $form_token,
            '{TIMESTAMP}' => $timestamp
        );

        $template = template_eval($template_album_admin_menu, $params);
    }

    $params = array(
        '{ALBUM_ID}' => $id,
    );

    return template_eval($template, $params);
}
and replace with
Code: [Select]
function html_albummenu($id)
{
    global $template_album_admin_menu, $template_album_admin_menu_nonadmin, $lang_album_admin_menu;

    static $template = '';

    if ($template == '') {
        list($timestamp, $form_token) = getFormToken();
        $params = array(
            '{CONFIRM_DELETE}' => $lang_album_admin_menu['confirm_delete'],
            '{DELETE}' => cpg_fetch_icon('delete', 1) . $lang_album_admin_menu['delete'],
            '{MODIFY}' => cpg_fetch_icon('modifyalb', 1) . $lang_album_admin_menu['modify'],
            '{EDIT_PICS}' => cpg_fetch_icon('edit', 1) . $lang_album_admin_menu['edit_pics'],
            '{FORM_TOKEN}' => $form_token,
            '{TIMESTAMP}' => $timestamp
        );

        if (GALLERY_ADMIN_MODE) {
            $template = template_eval($template_album_admin_menu, $params);
        } else {
            $template = template_eval($template_album_admin_menu_nonadmin, $params);
        }
    }

    $params = array(
        '{ALBUM_ID}' => $id,
    );

    return template_eval($template, $params);
}
Title: Re: Preventing users from inadvertantly deleting albums
Post by: timberguy on January 18, 2012, 05:41:09 pm
Is there a specific place I should place the code for theme.php ?  I'm using the curve theme.
Title: Re: Preventing users from inadvertantly deleting albums
Post by: Αndré on January 18, 2012, 06:39:24 pm
Right before the closing
Code: [Select]
?>is fine.
Title: Re: Preventing users from inadvertantly deleting albums
Post by: timberguy on January 18, 2012, 10:21:04 pm
Thank you very much. That worked perfectly.  :)
Title: Re: Preventing users from inadvertantly deleting albums
Post by: Αndré on January 19, 2012, 09:27:32 am
Please
tag your answer as "solved" by clicking on the "Topic Solved" button on the bar at the left hand side at the bottom of your thread.