Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Only admin can insert/edit keywords  (Read 4658 times)

0 Members and 1 Guest are viewing this topic.

nambroque

  • Coppermine regular visitor
  • **
  • Country: es
  • Offline Offline
  • Gender: Male
  • Posts: 85
    • Galería Fotometeo
Only admin can insert/edit keywords
« on: May 20, 2018, 09:56:15 am »

I would like admins to be the only users that are allowed to insert and edit keywords, so that we decide which pictures go to main albums of the gallery.
Probably, the most easy way to reach this would be by hiding the field of keyword for every group of users except admin.
I already got that in upload.php, but I don't know how to do it in editpics.php and editonepic.php files
May anyone help me with this?
Thanks in advance!
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Only admin can insert/edit keywords
« Reply #1 on: August 15, 2018, 02:15:07 pm »

Open edit_one_pic.php, find
Code: [Select]
print <<<EOT

    <tr>
        <td class="tableb" style="white-space: nowrap;">
            {$icon_array['title']}{$lang_common['title']}
        </td>
        <td width="100%" class="tableb" valign="top">
            <input type="text" style="width: 100%" name="title" maxlength="255" value="{$CURRENT_PIC['title']}" class="textinput" />
        </td>
    </tr>
    <tr>
        <td class="tableb" style="white-space: nowrap;">
            {$icon_array['file_name']}{$lang_common['filename']}
        </td>
        <td width="100%" class="tableb" valign="top">
            <tt>{$CONFIG['site_url']}{$CONFIG['fullpath']}{$filepath}</tt>
            <input type="text" name="filename" maxlength="255" size="40" value="{$CURRENT_PIC['filename']}" class="textinput" />
        </td>
    </tr>
    <tr>
        <td class="tableb" valign="top" style="white-space: nowrap;">
            {$icon_array['description']}{$lang_editpics_php['desc']}$captionLabel
        </td>
        <td class="tableb" valign="top">
            <textarea name="caption" id="caption" rows="1" cols="60" class="elastic textinput" onkeydown="textCounter(this, {$CONFIG['max_img_desc_length']});" onkeyup="textCounter(this, {$CONFIG['max_img_desc_length']});" style="max-height:200px;">{$CURRENT_PIC['caption']}</textarea>
        </td>
    </tr>
    <tr>
        <td class="tableb" style="white-space: nowrap;">
            {$icon_array['keyword']}{$keywords_insert1}<br />
            <a href="keyword_select.php" class="greybox">{$lang_common['keywords_insert2']}</a>
        </td>
        <td width="100%" class="tableb" valign="top">
            <input type="text" style="width: 100%" name="keywords" maxlength="255" value="{$CURRENT_PIC['keywords']}" id="keywords" class="textinput" />
        </td>
    </tr>
EOT;

if (GALLERY_ADMIN_MODE) {

    $checkYes = ($CURRENT_PIC['approved'] == 'YES') ? 'checked="checked"' : '';
    $checkNo = ($CURRENT_PIC['approved'] == 'NO') ? 'checked="checked"' : '';

    echo <<< EOT

    <tr>
        <td class="tableb" style="white-space: nowrap;">
            {$icon_array['file_approval']}{$lang_editpics_php['approval']}
        </td>
        <td width="100%" class="tableb" valign="top">
            <input type="radio" id="approved_yes" name="approved" value="YES" $checkYes />
            <label for="approved_yes" class="clickable_option">{$icon_array['file_approve']}{$lang_editpics_php['approved']}</label>
            &nbsp;&nbsp;
            <input type="radio" id="approved_no" name="approved" value="NO" $checkNo />
            <label for="approved_no" class="clickable_option">{$icon_array['file_disapprove']}{$lang_editpics_php['unapproved']}</label>
        </td>
    </tr>
EOT;
and replace with
Code: [Select]
print <<<EOT

    <tr>
        <td class="tableb" style="white-space: nowrap;">
            {$icon_array['title']}{$lang_common['title']}
        </td>
        <td width="100%" class="tableb" valign="top">
            <input type="text" style="width: 100%" name="title" maxlength="255" value="{$CURRENT_PIC['title']}" class="textinput" />
        </td>
    </tr>
    <tr>
        <td class="tableb" style="white-space: nowrap;">
            {$icon_array['file_name']}{$lang_common['filename']}
        </td>
        <td width="100%" class="tableb" valign="top">
            <tt>{$CONFIG['site_url']}{$CONFIG['fullpath']}{$filepath}</tt>
            <input type="text" name="filename" maxlength="255" size="40" value="{$CURRENT_PIC['filename']}" class="textinput" />
        </td>
    </tr>
    <tr>
        <td class="tableb" valign="top" style="white-space: nowrap;">
            {$icon_array['description']}{$lang_editpics_php['desc']}$captionLabel
        </td>
        <td class="tableb" valign="top">
            <textarea name="caption" id="caption" rows="1" cols="60" class="elastic textinput" onkeydown="textCounter(this, {$CONFIG['max_img_desc_length']});" onkeyup="textCounter(this, {$CONFIG['max_img_desc_length']});" style="max-height:200px;">{$CURRENT_PIC['caption']}</textarea>
        </td>
    </tr>
EOT;

if (GALLERY_ADMIN_MODE) {

    $checkYes = ($CURRENT_PIC['approved'] == 'YES') ? 'checked="checked"' : '';
    $checkNo = ($CURRENT_PIC['approved'] == 'NO') ? 'checked="checked"' : '';

    echo <<< EOT
    <tr>
        <td class="tableb" style="white-space: nowrap;">
            {$icon_array['keyword']}{$keywords_insert1}<br />
            <a href="keyword_select.php" class="greybox">{$lang_common['keywords_insert2']}</a>
        </td>
        <td width="100%" class="tableb" valign="top">
            <input type="text" style="width: 100%" name="keywords" maxlength="255" value="{$CURRENT_PIC['keywords']}" id="keywords" class="textinput" />
        </td>
    </tr>
    <tr>
        <td class="tableb" style="white-space: nowrap;">
            {$icon_array['file_approval']}{$lang_editpics_php['approval']}
        </td>
        <td width="100%" class="tableb" valign="top">
            <input type="radio" id="approved_yes" name="approved" value="YES" $checkYes />
            <label for="approved_yes" class="clickable_option">{$icon_array['file_approve']}{$lang_editpics_php['approved']}</label>
            &nbsp;&nbsp;
            <input type="radio" id="approved_no" name="approved" value="NO" $checkNo />
            <label for="approved_no" class="clickable_option">{$icon_array['file_disapprove']}{$lang_editpics_php['unapproved']}</label>
        </td>
    </tr>
EOT;

Open editpics.php, find
Code: [Select]
$data = array(
    array($icon_array['file_info'] . $lang_editpics_php['pic_info'], '', 3),
    array($icon_array['album'] . $lang_common['album'], 'aid', 1),
    array($icon_array['title'] . $lang_common['title'], 'title', 0, 255),
    array($icon_array['description'] . $captionLabel, 'caption', 2, $CONFIG['max_img_desc_length']),
    array($icon_array['keyword'] . $keywordLabel, 'keywords', 0, 255),
    array($CONFIG['user_field1_name'], 'user1', 0, 255),
    array($CONFIG['user_field2_name'], 'user2', 0, 255),
    array($CONFIG['user_field3_name'], 'user3', 0, 255),
    array($CONFIG['user_field4_name'], 'user4', 0, 255),
);
and below, add
Code: [Select]
if (!GALLERY_ADMIN_MODE) {
    unset($data[4]);
}
Logged
Pages: [1]   Go Up
 

Page created in 0.018 seconds with 20 queries.