4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: thunderstrike on October 03, 2007, 03:05:46 AM

Title: [MOD] - Show edit and delete link in new images of index page
Post by: thunderstrike on October 03, 2007, 03:05:46 AM
This show [edit] and [delete] in new images table of index page for details image (same in details for admin).

In index.php file,

find:

Quote
while ($image_row = $site_db->fetch_array($result)){
    if ($count == 0) {
      $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
      $new_images .= "<tr class=\"imagerow".$row_bg_number."\">\n";
    }
    $new_images .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";

    show_image($image_row);
    $new_images .= $site_template->parse_template("thumbnail_bit");
    $new_images .= "\n</td>\n";
    $count++;
    if ($count == $config['image_cells']) {
      $new_images .= "</tr>\n";
      $count = 0;
    }
  } // end while

replace:

Code: [Select]
while ($image_row = $site_db->fetch_array($result)){
    if ($count == 0) {
      $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
      $new_images .= "<tr class=\"imagerow".$row_bg_number."\">\n";     
    }
   
    $is_image_owner = ($image_row['user_id'] > USER_AWAITING && $user_info['user_id'] == $image_row['user_id']) ? 1 : 0;
    if ($user_info['user_level'] == ADMIN) {
        $admin_links .= "<a href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("images.php?action=editimage&image_id=".$image_row['image_id']))."\" target=\"_blank\">".$lang['edit']."</a>&nbsp;";
        $admin_links .= "<a href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("images.php?action=removeimage&image_id=".$image_row['image_id']))."\" target=\"_blank\">".$lang['delete']."</a>";       
    } elseif ($is_image_owner) {
        $admin_links .= ($config['user_edit_image'] != 1) ? "" : "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=editimage&amp;".URL_IMAGE_ID."=".$image_row['image_id'])."\">".$lang['edit']."</a>&nbsp;";
        $admin_links .= ($config['user_delete_image'] != 1) ? "" : "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=removeimage&amp;".URL_IMAGE_ID."=".$image_row['image_id'])."\">".$lang['delete']."</a>";
        unset ($is_image_owner);
    }  
    $new_images .= "<td width=\"".$imgtable_width."\" valign=\"top\">" . ((isset($admin_links)) ? $admin_links  : "") . "\n";

    show_image($image_row);   

    $new_images .= $site_template->parse_template("thumbnail_bit");
    $new_images .= "\n</td>\n";
    $count++;
    if ($count == $config['image_cells']) {
      $new_images .= "</tr>\n";
      $count = 0;
    }
    unset ($admin_links);
  } // end while
Title: Re: [MOD] - Show edit and delete link in new images of index page
Post by: thunderstrike on October 03, 2007, 10:28:22 PM
I add image owner in MOD now.
Title: Re: [MOD] - Show edit and delete link in new images of index page
Post by: Rembrandt on July 23, 2011, 07:32:38 AM
Hi!

works!

1.)replace the code above with these, and they can put the "admin link" in the "thumbnail_bit" where ever you want:

  while ($image_row = $site_db->fetch_array($result)){
    if ($count == 0) {
      $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
      $new_images .= "<tr class=\"imagerow".$row_bg_number."\">\n";     
    }
    $new_images .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";
    $admin_links="";
    $is_image_owner = ($image_row['user_id'] > USER_AWAITING && $user_info['user_id'] == $image_row['user_id']) ? 1 : 0;
    if ($user_info['user_level'] == ADMIN) {
        $admin_links .= "<a href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("images.php?action=editimage&image_id=".$image_row['image_id']))."\" target=\"_blank\">".$lang['edit']."</a>&nbsp;";
        $admin_links .= "<a href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("images.php?action=removeimage&image_id=".$image_row['image_id']))."\" target=\"_blank\">".$lang['delete']."</a>";       
    } elseif ($is_image_owner) {
        $admin_links .= ($config['user_edit_image'] != 1) ? "" : "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=editimage&amp;".URL_IMAGE_ID."=".$image_row['image_id'])."\">".$lang['edit']."</a>&nbsp;";
        $admin_links .= ($config['user_delete_image'] != 1) ? "" : "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=removeimage&amp;".URL_IMAGE_ID."=".$image_row['image_id'])."\">".$lang['delete']."</a>";
        unset ($is_image_owner);
    }

    $new_images .=  $site_template->register_vars("admin_links", $admin_links);
    show_image($image_row);   

    $new_images .= $site_template->parse_template("thumbnail_bit");
    $new_images .= "\n</td>\n";
    $count++;
    if ($count == $config['image_cells']) {
      $new_images .= "</tr>\n";
      $count = 0;
    }
    unset ($admin_links);
  } // end while


2.) now you can write  "{admin_links}" where ever you want in your templates/yourTemplates/thumbnail_bit (example):
Code: [Select]
<!-- you wish detail page in a small javascript open window, use {thumbnail_openwindow} -->
{thumbnail}<br />
<b>{image_name}</b> {if image_is_new}<sup class="new">{lang_new}</sup>{endif image_is_new} ({user_name_link})
<br />
<a href="{cat_url}">{cat_name}</a><br />
{if allow_comments}{lang_comments} {image_comments}{endif allow_comments}<br />
{lightbox_button}<br>
{admin_links}


mfg Andi
Title: Re: [MOD] - Show edit and delete link in new images of index page
Post by: son_gokou on October 27, 2014, 12:21:19 PM
admin_links is not working for me. I can't see EDIT or ERASE buttons on images pages.

Any suggestion?
Title: Re: [MOD] - Show edit and delete link in new images of index page
Post by: Rembrandt on October 27, 2014, 12:34:37 PM
it works
Title: Re: [MOD] - Show edit and delete link in new images of index page
Post by: son_gokou on October 27, 2014, 12:37:36 PM
Sorry, I didn't explain me well.
For me, the edit and erase buttons on image pages are not appearing since some weeks ago.