• [MOD] Multi-Lightboxes v1.03.2 (2011-09-20) 4 0 5 1
Currently:  

Author Topic: [MOD] Multi-Lightboxes v1.03.2 (2011-09-20)  (Read 210465 times)

0 Members and 1 Guest are viewing this topic.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
[MOD] Multi-Lightboxes v1.03.2 (2011-09-20)
« on: December 01, 2005, 08:09:49 AM »
----------- [ Introduction ] -------------
With this mod members will have ability have more then one lightbox (album) and share them with others (read only).


----------- [ Features ] ------------
  • Unlimited/limited number of lightboxes.
  • Shared/private lightboxes
  • Global/per member settings: allowed number of lightboxes and if allowed share lightboxes

Lightbox manager:


Shared lightboxes from member's profile page:



Before you start the installation process:
- this mod was created on fresh 4images v1.7.1 and has not been tested on v1.7
(done. tested on fresh v1.7)
- I have not tested it against other mods, such as [MOD] Lightbox for GUESTs v1.2
(done. post updated with little modifications for compability with "Lightbox for Guests" mod)


---------- [ Changed files ] ----------

lightbox.php
details.php
download.php
member.php
includes/functions.php
includes/page_header.php
includes/sessions.php
includes/db_field_definitions.php
admin/settings.php
admin/images.php
lang/
<your language>/admin.php
lang/
<your language>/main.php
templates/
<your template>/lightbox.html
templates/
<your template>/member_profile.html
templates/
<your template>/user_logininfo.html
templates/
<your template>/style.css



---------- [ Installation ] -----------

Step 1
Download attached package
Unzip it and upload all files, restoring this file tree:

multilightbox_install.php
templates/
<your template>/lightbox_manage.html
templates/
<your template>/lightbox_dropdown.html

Login as administrator and run the multilightbox_install.php (type in your browser: http://youraddress/path-where-this-file-is/multilightbox_install.php[/b])

Alternatively you can run this MySQL query:
Code: [Select]
ALTER TABLE 4images_users ADD user_lightbox MEDIUMINT( 8 ) UNSIGNED NOT NULL;
ALTER TABLE 4images_users ADD user_lightbox_count SMALLINT( 3 ) DEFAULT '0' NOT NULL;
ALTER TABLE 4images_users ADD user_lightbox_private TINYINT( 1 ) UNSIGNED DEFAULT '1' NOT NULL;

ALTER TABLE 4images_lightboxes ADD id MEDIUMINT( 12 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;
ALTER TABLE 4images_lightboxes ADD lightbox_name VARCHAR( 32 ) NOT NULL;
ALTER TABLE 4images_lightboxes ADD lightbox_private TINYINT( 1 ) UNSIGNED DEFAULT '1' NOT NULL;
ALTER TABLE 4images_lightboxes ADD INDEX ( lightbox_private );

INSERT INTO 4images_settings ( setting_name , setting_value ) VALUES ( 'lightbox_count', '5' ), ( 'lightbox_share', '1' );

Ones the database was successfuly updated, delete multilightbox_install.php



Step 2
Open lightbox.php
If you installed [MOD] Lightbox for GUESTs v1.2 MOD, skip this step and continue with Step 2.1
Find:
Code: [Select]
if ($user_info['user_level'] == GUEST || $user_info['user_level'] == USER_AWAITING) {Replace with:
Code: [Select]
/*
  MOD MULTI-LIGHTBOXES
  START REPLACE
*/
if (($user_info['user_level'] == GUEST || $user_info['user_level'] == USER_AWAITING) && !((isset($HTTP_POST_VARS['lightbox_id']) && $HTTP_POST_VARS['lightbox_id']) || (isset($HTTP_GET_VARS['lightbox_id']) && $HTTP_GET_VARS['lightbox_id']))) {
/*
  MOD MULTI-LIGHTBOXES
  END REPLACE
*/


Step 2.1
Find:
Code: [Select]
//-----------------------------------------------------
//--- Show Images -------------------------------------
//-----------------------------------------------------

Replace with:
Code: [Select]
/*
  MOD MULTI-LIGHTBOXES
  START REPLACE
*/
if ($user_info['user_level'] == GUEST || ($action != "manage" && $action != "save"))
{
  $action = ($action == "clearlightbox" && $user_info['user_level'] >= USER) ? "manage" : "show";
}
$txt_clickstream = "";
$lightbox_name = "";

$name_error = 0;
$status = array();
$user_info['user_lightbox'] = ($user_info['user_level'] >= USER && $user_info['user_lightbox']) ? $user_info['user_lightbox'] : 0;
$limit = ($user_info['user_lightbox_count'] == -1 || !$config['lightbox_count'] || $user_info['user_level'] == ADMIN) ? -1 : (($user_info['user_lightbox_count']) ? $user_info['user_lightbox_count'] : $config['lightbox_count']);
$total = count($user_info['lightboxes']);
$total_update = $total;
unset($private_new, $name_new);
//-----------------------------------------------------
//--- Update Lightboxes Settings ----------------------
//-----------------------------------------------------
if ($action == "save")
{
  for ($i = 1; $i <= $total_update; $i++)
  {
    $name = (isset($HTTP_POST_VARS['name_'.$i])) ? un_htmlspecialchars(trim($HTTP_POST_VARS['name_'.$i])) : "";
    $id = (isset($HTTP_POST_VARS['id_'.$i])) ? $HTTP_POST_VARS['id_'.$i] : 0;
    $delete = (isset($HTTP_POST_VARS['delete_'.$i])) ? 1 : 0;
    $clear = (isset($HTTP_POST_VARS['clear_'.$i])) ? 1 : 0;
    $private = (isset($HTTP_POST_VARS['private_'.$i])) ? 1 : 0;
    if ($delete && !$clear && $id && $id != $user_info['user_lightbox'])
    {
      $sql = "DELETE FROM ".LIGHTBOXES_TABLE." WHERE id = ".$id;
      if ($site_db->query($sql))
      {
        $status[$id]['msg'] = (($status[$id]['msg'] != "") ? "<br />" : "").preg_replace("/".$site_template->start."name".$site_template->end."/iU", stripslashes($name), $lang['mlightbox_delete_success']);
        $status[$id]['error'] = 0;
        $total--;
        unset($user_info['lightboxes'][$id]);
      }
      else
      {
        $status[$id]['msg'] = (($status[$id]['msg'] != "") ? "<br />" : "").preg_replace("/".$site_template->start."name".$site_template->end."/iU", stripslashes($name), $lang['mlightbox_delete_error']);
        $status[$id]['error'] = 1;
      }
    }
    else
    {
      if (!empty($name))
      {
        $do_clear = ($clear) ? ", lightbox_image_ids = ''" : "";
        $sql = "UPDATE ".LIGHTBOXES_TABLE." SET lightbox_name = '".$name."', lightbox_private = ".$private.$do_clear." WHERE id = ".$id;
        if ($site_db->query($sql))
        {
          $status[$id]['msg'] = preg_replace("/".$site_template->start."name".$site_template->end."/iU", stripslashes($name), $lang['lightbox_update_success']);
          $status[$id]['msg'] .= ($clear) ? "<br />".preg_replace("/".$site_template->start."name".$site_template->end."/iU", stripslashes($name), $lang['lightbox_delete_success']) : "";
          $status[$id]['error'] = 0;
          $user_info['lightboxes'][$id]['name'] = stripslashes($name);
          $user_info['lightboxes'][$id]['private'] = $private;
          $user_info['lightboxes'][$id]['count'] = ($clear) ? 0 : $user_info['lightboxes'][$id]['count'];
        }
        else
        {
          $status[$id]['msg'] = preg_replace("/".$site_template->start."name".$site_template->end."/iU", stripslashes($name), $lang['lightbox_update_error']);
          $status[$id]['msg'] .= ($clear) ? "<br />".preg_replace("/".$site_template->start."name".$site_template->end."/iU", stripslashes($name), $lang['lightbox_delete_error']) : "";
          $status[$id]['error'] = 1;
        }
      }
      elseif ($id)
      {
          $name_error++;
          $status[$id]['error'] = 1;
      }
    }
  }
  $name_new = un_htmlspecialchars(trim($HTTP_POST_VARS['name_new']));
  $private_new = (isset($HTTP_POST_VARS['private_new'])) ? 1 : 0;
//  if ($name_new && !$name_error)
  if ($name_new)
  {
    if ($limit == -1 || $total < $limit)
    {
      $lightbox_id = get_random_key(LIGHTBOXES_TABLE, "lightbox_id");
      $sql = "INSERT INTO ".LIGHTBOXES_TABLE."
              (lightbox_id, user_id, lightbox_lastaction, lightbox_image_ids, lightbox_name, lightbox_private)
              VALUES
              ('$lightbox_id', ".$user_info[$user_table_fields['user_id']].", ".time().", '', '".$name_new."', ".$private_new.")";
      if ($site_db->query($sql))
      {
        $total++;
        $id = $site_db->get_insert_id();
        $status[$id]['msg'] = preg_replace("/".$site_template->start."name".$site_template->end."/iU", stripslashes($name_new), $lang['lightbox_create_success']);
        $status[$id]['error'] = 0;
        $user_info['lightboxes'][$id]['name'] = stripslashes($name_new);
        $user_info['lightboxes'][$id]['id'] = $id;
        $user_info['lightboxes'][$id]['lightbox_id'] = $lightbox_id;
        $user_info['lightboxes'][$id]['private'] = $private_new;
        $user_info['lightboxes'][$id]['count'] = 0;
        unset($private_new, $name_new);
      }
      else
      {
        $status[0]['msg'] = preg_replace("/".$site_template->start."name".$site_template->end."/iU", stripslashes($name_new), $lang['lightbox_create_error']);
        $status[0]['error'] = 1;
      }
    }
    else
    {
      $status[0]['msg'] = preg_replace("/".$site_template->start."name".$site_template->end."/iU", stripslashes($name_new), $lang['lightbox_create_error']);
      $status[0]['error'] = 1;
    }
  }
  else
  {
    unset($private_new, $name_new);
  }

  $name = 0;
  $msg = array("good" => (($msg) ? array($msg) : array()), "error" => array(), "plain" => array());
  foreach ($status as $key)
  {
    if ($key['msg'])
    {
      if ($key['error'])
      {
        $msg['error'][] = $key['msg'];
      }
      else
      {
        $msg['good'][] = $key['msg'];
      }
    }
  }
  if ($name_error)
  {
    $msg['error'][] = preg_replace("/".$site_template->start."lightbox".$site_template->end."/iU", (($name_error > 1) ? $lang['lightbox_plural'] : $lang['lightbox_single']), $lang['lightbox_name_error']);
  }
  $action = "manage";
  $msg = (empty($msg)) ? "" : get_msg($msg);
}

if ($user_info['user_level'] >= USER)
{
  $user_lightbox_dropdown = ($total > 1) ? get_dropdown_options("user_lightbox", $user_info['lightboxes_list'], $user_info['user_lightbox'], 1, 0, 1) : "";
}
else
{
  $user_lightbox_dropdown = "";
}
$site_template->register_vars("user_lightbox_dropdown", $user_lightbox_dropdown);
$user_lightbox_dropdown = ($user_lightbox_dropdown) ? $site_template->parse_template("lightbox_dropdown") : "";
$site_template->register_vars("user_lightbox_form", $user_lightbox_dropdown);

//-----------------------------------------------------
//--- Manage Lightboxes -------------------------------
//-----------------------------------------------------
if ($action == "manage")
{
  $txt_clickstream = "<a href=\"".$site_sess->url(ROOT_PATH."lightbox.php")."\">".$lang['lightbox']."</a>".$config['category_separator'].$lang['lightbox_settings'];
  $i = 1;
  $maxlength = 32;
  $list = "";
  foreach ($user_info['lightboxes'] as $key => $val)
  {
    $list .= "<tr".(isset($status[$val['id']]['error']) ? (($status[$val['id']]['error']) ? " class=\"mlightbox0\"" : " class=\"mlightbox1\"") : "")." align=\"center\">\n";
    $list .= "<td>".$i.".</td>\n";
    $list .= "<td><input name=\"name_".$i."\" value=\"".str_replace("\"", "&quot;", $val['name'])."\" maxlength=\"".$maxlength."\" class=\"lightboxinput\" /></td>\n";
    $list .= "<td><a href=\"".$site_sess->url(ROOT_PATH."lightbox.php?user_lightbox=".$val['id'])."\">".$val['count']."</a></td>\n";
    if ($user_info['user_lightbox_private'] && $config['lightbox_share'] || $user_info['user_level'] == ADMIN)
    {
      $list .= "<td><input name=\"private_".$i."\" value=\"1\" type=\"checkbox\"".(($val['private']) ? " checked" : "")." /></td>\n";
    }
    $list .= "<td><input name=\"clear_".$i."\" value=\"1\" type=\"checkbox\" /></td>\n";
    if ($key != $user_info['user_lightbox'])
    {
      $list .= "<td><input name=\"delete_".$i."\" value=\"1\" type=\"checkbox\" />\n";
    }
    else
    {
      $list .= "<td>&nbsp;</td>";
    }
    $list .= "<input name=\"id_".$i."\" value=\"".$val['id']."\" type=\"hidden\" /></td>\n</tr>\n";
    $i++;
  }
  if ($limit == -1 || $total < $limit)
  {
    $list .= "<tr>\n";
    $list .= "<td>&nbsp;</td>\n";
    $list .= "<td colspan=\"2\">".$lang['add_new']."&nbsp;<input name=\"name_new\" value=\"".$name_new."\" size=\"12\" maxlength=\"".$maxlength."\" class=\"lightboxinputnew\" /></td>\n";
    if ($user_info['user_lightbox_private'] && $config['lightbox_share'] || $user_info['user_level'] == ADMIN)
    {
      $list .= "<td align=\"middle\"><input name=\"private_new\" value=\"1\" type=\"checkbox\"".((isset($private_new)) ? (($private_new) ? " checked" : "") : " checked")." /></td>\n";
    }
    $list .= "<td>&nbsp;</td>\n";
    $list .= "<td>&nbsp;</td>\n";
    $list .= "</tr>\n";
  }
  $list .= "<input type=\"hidden\" name=\"action\" value=\"save\" />";
$limit_prc = ($limit) ? round(($total * 100) / $limit) : 0;
$lang_limit = ($limit != -1) ? preg_replace(array("/".$site_template->start."limit".$site_template->end."/siU", "/".$site_template->start."total".$site_template->end."/siU"), array($limit, $total), $lang['lightbox_limit']) : $lang['lightbox_unlimited'];
  $site_template->register_vars(array(
    "list" => $list,
    "limit_prc" => $limit_prc,
    "lang_limit" => $lang_limit,
    "lang_name" => $lang['name'],
    "lang_private" => ($user_info['user_lightbox_private'] && $config['lightbox_share'] || $user_info['user_level'] == ADMIN) ? $lang['private'] : "",
    "lang_delete" => ($total > 1) ? $lang['lang_delete'] : "",
    "lang_images" => $lang['images'],
    "lang_clear" => $lang['clear'],
    "lang_submit" => $lang['save'],
    "lang_reset" => $lang['reset']
  ));
  $site_template->register_vars(array(
    "thumbnails" => $site_template->parse_template('lightbox_manage'),
    "lightbox_in_manage" => 1,
    "lightbox_notin_manage" => 0,
    "lightbox_lastaction" => (empty($user_info['lightbox_lastaction'])) ? format_date($config['date_format']." ".$config['time_format'], $user_info['lightbox_lastaction']) : "n/a",
  ));
  $lightbox_name = $lang['lightbox_settings'];
}
//-----------------------------------------------------
//--- Show Images -------------------------------------
//-----------------------------------------------------
if ($action == "show")
{
  $lightbox_id = (isset($HTTP_POST_VARS['lightbox_id']) && $HTTP_POST_VARS['lightbox_id']) ? $HTTP_POST_VARS['lightbox_id'] : ((isset($HTTP_GET_VARS['lightbox_id']) && $HTTP_GET_VARS['lightbox_id']) ? $HTTP_GET_VARS['lightbox_id'] : 0);
  $ids = "";
  if ($lightbox_id)
  {
    $sql = "SELECT l.lightbox_id, l.lightbox_name, l.lightbox_private, l.lightbox_image_ids, l.user_id, u.user_name, u.user_lightbox_private
            FROM ".LIGHTBOXES_TABLE." l
            LEFT JOIN ".USERS_TABLE." u ON u.user_id = l.user_id
            WHERE l.lightbox_id = '".$lightbox_id."'";
    if ($row = $site_db->query_firstrow($sql))
    {
      $ids = (!$row['lightbox_private'] && $row['user_lightbox_private'] && $config['lightbox_share'] || $user_info['user_level'] == ADMIN ) ? $row['lightbox_image_ids'] : "";//$user_info['lightbox_image_ids'];
      $lightbox_name = stripslashes($row['lightbox_name'])." (".$row['user_name'].")";
    }
    else
    {
      $lightbox_name = "";
    }
  }
  else
  {
    $lightbox_name = $user_info['lightboxes'][$user_info['user_lightbox']]['name'];
  }
  if ($lightbox_name)
  {
    $txt_clickstream = "<a href=\"".$site_sess->url(ROOT_PATH."lightbox.php")."\">".$lang['lightbox']."</a>".$config['category_separator'].$lightbox_name;
  }
  else
  {
    $txt_clickstream = $lang['lightbox'];
  }
  $site_template->register_vars(array(
    "lang_lightbox_manage" => $lang['lightbox_manage'],
    "url_lightbox_manage" => ($user_info['user_level'] >= USER && !$lightbox_id) ? $site_sess->url(ROOT_PATH."lightbox.php?action=manage") : "",
    "lightbox_in_manage" => 0,
    "lightbox_notin_manage" => 1,

  ));
/*
  MOD MULTI-LIGHTBOXES
  END REPLACE
*/

Step 2.2
Find:
Code: [Select]
if (!empty($user_info['lightbox_image_ids']))  {
  $image_id_sql = str_replace(" ", ", ", trim($user_info['lightbox_image_ids']));
Replace with:
Code: [Select]
/*
  MOD MULTI-LIGHTBOXES
  START REPLACE
*/
  if (!empty($user_info['lightbox_image_ids']) || $lightbox_id)  {
    $image_id_sql = str_replace(" ", ", ", trim((($lightbox_id) ? $ids : $user_info['lightbox_image_ids'])));
    $image_id_sql = (empty($image_id_sql)) ? 0 : $image_id_sql;
/*
  MOD MULTI-LIGHTBOXES
  END REPLACE
*/

Step 2.3
Find:
Code: [Select]
   show_image($image_row, "lightbox");Replace with:
Code: [Select]
/*
  MOD MULTI-LIGHTBOXES
  START REPLACE
*/
    show_image($image_row, "lightbox".(($lightbox_id) ? "&lightbox_id=".$lightbox_id : ""));
/*
  MOD MULTI-LIGHTBOXES
  END REPLACE
*/

Step 2.4
Find:
Code: [Select]
$clickstream = "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator'].$lang['lightbox']."</span>";Replace with:
Code: [Select]
/*
  MOD MULTI-LIGHTBOXES
  START REPLACE
*/
}
$clickstream = "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator'].$txt_clickstream."</span>";
/*
  MOD MULTI-LIGHTBOXES
  END REPLACE
*/

Step 2.5a (For people without [MOD] Lightbox for GUESTs installed)
4images v1.7 - 1.7.3

Find:
Code: [Select]
 if (!empty($user_info['lightbox_image_ids'])) {
    $download_button = "<a href=\"".$site_sess->url(ROOT_PATH."download.php?action=lightbox")."\"><img src=\"".get_gallery_image("download_zip.gif")."\" border=\"0\" alt=\"\" /></a>";
Replace with:
Code: [Select]
/*
  MOD MULTI-LIGHTBOXES
  START REPLACE
*/
  if (($lightbox_id && !empty($ids)) || (!$lightbox_id && !empty($user_info['lightbox_image_ids']))) {
    $download_button = "<a href=\"".$site_sess->url(ROOT_PATH."download.php?action=lightbox".(($lightbox_id) ? "&lightbox_id=".$lightbox_id : ""))."\"><img src=\"".get_gallery_image("download_zip.gif")."\" border=\"0\" alt=\"\" /></a>";
/*
  MOD MULTI-LIGHTBOXES
  END REPLACE
*/

4images v1.7.4 and newer

Find:
Code: [Select]
 if ($download_allowed && !empty($user_info['lightbox_image_ids'])) {
    $download_button = "<a href=\"".$site_sess->url(ROOT_PATH."download.php?action=lightbox")."\"><img src=\"".get_gallery_image("download_zip.gif")."\" border=\"0\" alt=\"\" /></a>";
Replace with:
Code: [Select]
/*
  MOD MULTI-LIGHTBOXES
  START REPLACE
*/
  if ($download_allowed && (($lightbox_id && !empty($ids)) || (!$lightbox_id && !empty($user_info['lightbox_image_ids'])))) {
    $download_button = "<a href=\"".$site_sess->url(ROOT_PATH."download.php?action=lightbox".(($lightbox_id) ? "&lightbox_id=".$lightbox_id : ""))."\"><img src=\"".get_gallery_image("download_zip.gif")."\" border=\"0\" alt=\"\" /></a>";
/*
  MOD MULTI-LIGHTBOXES
  END REPLACE
*/


Step 2.5b (For people with [MOD] Lightbox for GUESTs installed)
Find:
Code: [Select]
 if (!empty($user_info['lightbox_image_ids']) && $user_info['user_level'] != GUEST) {
    $download_button = "<a href=\"".$site_sess->url(ROOT_PATH."download.php?action=lightbox")."\"><img src=\"".get_gallery_image("download_zip.gif")."\" border=\"0\" alt=\"\" /></a>";
Replace with:
Code: [Select]
/*
  MOD MULTI-LIGHTBOXES
  START REPLACE
*/
  if ($user_info['user_level'] != GUEST && (($lightbox_id && !empty($ids)) || (!$lightbox_id && !empty($user_info['lightbox_image_ids'])))) {
    $download_button = "<a href=\"".$site_sess->url(ROOT_PATH."download.php?action=lightbox".(($lightbox_id) ? "&lightbox_id=".$lightbox_id : ""))."\"><img src=\"".get_gallery_image("download_zip.gif")."\" border=\"0\" alt=\"\" /></a>";
/*
  MOD MULTI-LIGHTBOXES
  END REPLACE
*/


Step 2.5c (For people with [MOD] - Restrict users to use e-card and download if they have not voted first installed)
Find:
Code: [Select]
$array_lightbox_image_ids = explode(" ", $user_info['lightbox_image_ids']); // put lightboxed pics in an array

foreach ($array_lightbox_image_ids as $element) {
if (!in_array ($element, $rated_images)) { // if current lightboxed pics in not found in rated pics by user
$one_not_rated = 1;
   }
}
   if (!empty($user_info['lightbox_image_ids']) && !$one_not_rated) { // !$one_not_rated  :  means all pics in lightbox have been rated
//-------------------------------------------[/[Mod] Restrict users to use e-card and download if they have not voted first]

   $download_button = "<a href=\"".$site_sess->url(ROOT_PATH."download.php?action=lightbox")."\"><img src=\"".get_gallery_image("download_zip.gif")."\" border=\"0\" alt=\"\" /></a>";
Replace with:
Code: [Select]
/*
  MOD MULTI-LIGHTBOXES
  START REPLACE
*/
$array_lightbox_image_ids = explode(" ", (($lightbox_id && !empty($ids)) ? $ids : $user_info['lightbox_image_ids'])); // put lightboxed pics in an array
$one_not_rated = 0;
foreach ($array_lightbox_image_ids as $element) {
if (!in_array ($element, $rated_images)) { // if current lightboxed pics in not found in rated pics by user
$one_not_rated = 1;
   }
}
   if ((($lightbox_id && !empty($ids)) || (!$lightbox_id && !empty($user_info['lightbox_image_ids']))) && !$one_not_rated) { // !$one_not_rated  :  means all pics in lightbox have been rated
//-------------------------------------------[/[Mod] Restrict users to use e-card and download if they have not voted first]

   $download_button = "<a href=\"".$site_sess->url(ROOT_PATH."download.php?action=lightbox".(($lightbox_id) ? "&lightbox_id=".$lightbox_id : ""))."\"><img src=\"".get_gallery_image("download_zip.gif")."\" border=\"0\" alt=\"\" /></a>";
/*
  MOD MULTI-LIGHTBOXES
  END REPLACE
*/


Step 2.6 (added 19-02-2006)
Find:
Code: [Select]
$link_arg = $site_sess->url(ROOT_PATH."lightbox.php");Replace with:
Code: [Select]
/*
  MOD MULTI-LIGHTBOXES
  START REPLACE
*/
$link_arg = ROOT_PATH."lightbox.php".(($lightbox_id) ? "?lightbox_id=".$lightbox_id : "");
/*
  MOD MULTI-LIGHTBOXES
  END REPLACE
*/



Step 3
Open details.php
Find:
Code: [Select]
show_image($image_row, $mode, 0, 1);Replace with:
Code: [Select]
/*
  MOD MULTI-LIGHTBOXES
  START REPLACE
*/
$lightbox_id = (isset($HTTP_POST_VARS['lightbox_id']) && $HTTP_POST_VARS['lightbox_id']) ? $HTTP_POST_VARS['lightbox_id'] : ((isset($HTTP_GET_VARS['lightbox_id']) && $HTTP_GET_VARS['lightbox_id']) ? $HTTP_GET_VARS['lightbox_id'] : 0);
show_image($image_row, $mode.(($lightbox_id) ? "&lightbox_id=".$lightbox_id : ""), 0, 1);
/*
  MOD MULTI-LIGHTBOXES
  END REPLACE
*/

Step 3.1
Find:
Code: [Select]
 if (!empty($user_info['lightbox_image_ids'])) {
    $image_id_sql = str_replace(" ", ", ", trim($user_info['lightbox_image_ids']));
Replace with:
Code: [Select]
/*
  MOD MULTI-LIGHTBOXES
  START REPLACE
*/
  $ids = $user_info['lightbox_image_ids'];
  if ($lightbox_id)
  {
    $sql = "SELECT l.lightbox_id, l.lightbox_name, l.lightbox_private, l.lightbox_image_ids, l.user_id, u.user_name, u.user_lightbox_private
            FROM ".LIGHTBOXES_TABLE." l
            LEFT JOIN ".USERS_TABLE." u ON u.user_id = l.user_id
            WHERE l.lightbox_id = '".$lightbox_id."'";
    if ($row = $site_db->query_firstrow($sql))
    {
      $ids = (!$row['lightbox_private'] && $row['user_lightbox_private'] && $config['lightbox_share'] || $user_info['user_level'] == ADMIN ) ? $row['lightbox_image_ids'] : "";//$user_info['lightbox_image_ids'];
      $lightbox_name = $row['lightbox_name']." (".$row['user_name'].")";
    }
    else
    {
      $lightbox_name = "";
    }
  }
  else
  {
    $lightbox_name = $user_info['lightboxes'][$user_info['user_lightbox']]['name'];
  }
  $txt_clickstream = $lang['lightbox'].(($lightbox_name) ? " - ".$lightbox_name : "");
  if (!empty($ids)) {
    $image_id_sql = str_replace(" ", ", ", trim($ids));
/*
  MOD MULTI-LIGHTBOXES
  END REPLACE
*/

Step 3.2
Find:
Code: [Select]
 $next_image_url = $site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$next_image_id.((!empty($mode)) ? "&amp;mode=".$mode : ""));Replace with:
Code: [Select]
/*
  MOD MULTI-LIGHTBOXES
  START REPLACE
*/
  $next_image_url = $site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$next_image_id.((!empty($mode)) ? "&amp;mode=".$mode.(($lightbox_id) ? "&lightbox_id=".$lightbox_id : "") : ""));
/*
  MOD MULTI-LIGHTBOXES
  END REPLACE
*/

Step 3.3
Find:
Code: [Select]
 $prev_image_url = $site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$prev_image_id.((!empty($mode)) ? "&amp;mode=".$mode : ""));Replace with:
Code: [Select]
/*
  MOD MULTI-LIGHTBOXES
  START REPLACE
*/
  $prev_image_url = $site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$prev_image_id.((!empty($mode)) ? "&amp;mode=".$mode.(($lightbox_id) ? "&lightbox_id=".$lightbox_id : "") : ""));
/*
  MOD MULTI-LIGHTBOXES
  END REPLACE
*/

Step 3.5
Find:
Code: [Select]
 $clickstream .= "<a href=\"".$site_sess->url(ROOT_PATH."lightbox.php".$page_url)."\" class=\"clickstream\">".$lang['lightbox']."</a>".$config['category_separator'];Replace with:
Code: [Select]
/*
  MOD MULTI-LIGHTBOXES
  START REPLACE
*/
  $page_url .= ($lightbox_id) ? (($page_url) ? "&" : "?")."lightbox_id=".$lightbox_id : "";
  $clickstream .= "<a href=\"".$site_sess->url(ROOT_PATH."lightbox.php".$page_url)."\" class=\"clickstream\">".$txt_clickstream."</a>".$config['category_separator'];
/*
  MOD MULTI-LIGHTBOXES
  END REPLACE
*/


Step 4
Open member.php
Find in 4images v1.7-1.7.6:
Code: [Select]
   $user_homepage = (isset($user_row['user_homepage'])) ? format_url($user_row['user_homepage']) : REPLACE_EMPTY;Find in 4images v1.7.7 or newer:
Code: [Select]
   $user_homepage = (isset($user_row['user_homepage'])) ? format_text(format_url($user_row['user_homepage']), 2) : REPLACE_EMPTY;
Insert above:
Code: [Select]
/*
  MOD MULTI-LIGHTBOXES
  START INSERT
*/
    $user_lightbox = "";
    $limit = ($user_row['user_lightbox_count'] == -1 || !$config['lightbox_count'] || $user_row['user_level'] == ADMIN) ? -1 : (($user_row['user_lightbox_count']) ? $user_row['user_lightbox_count'] : $config['lightbox_count']);
    if ((($user_row['user_lightbox_private'] || $user_row['user_level'] == ADMIN) && $config['lightbox_share']) || $user_info['user_level'] == ADMIN)
    {
      $condition = "";
      if ($limit != -1)
      {
        $condition = " LIMIT ".$limit;
      }
      $condition;
      $sql = "SELECT lightbox_id, lightbox_name, lightbox_private, lightbox_image_ids
              FROM ".LIGHTBOXES_TABLE."
              WHERE user_id = ".$user_row['user_id'].$condition;
      $result = $site_db->query($sql);
      if ($result)
      {
        while ($row = $site_db->fetch_array($result))
        {
          if (!$row['lightbox_private'] || $user_info['user_level'] == ADMIN)
          {
            $user_lightbox .= (($user_lightbox) ? "<br />" : "").(($user_info['user_level'] == ADMIN) ? ((!$row['lightbox_private']) ? "+ " : "- ") : "")."<a href=\"".$site_sess->url(ROOT_PATH."lightbox.php?lightbox_id=".$row['lightbox_id'])."\">".$row['lightbox_name']." (".((trim($row['lightbox_image_ids'])) ? count(explode(" ", trim($row['lightbox_image_ids']))) : 0).")</a>\n";
          }
        }
      }
    }
    $site_template->register_vars(array(
      "user_lightbox" => $user_lightbox,
      "lang_user_lightbox" => $lang['user_lightbox'],
    ));
/*
  MOD MULTI-LIGHTBOXES
  END INSERT
*/

Step 4.1
Find:
Code: [Select]
 $user_invisible = (isset($HTTP_POST_VARS['user_invisible'])) ? intval($HTTP_POST_VARS['user_invisible']) : 0;Insert below:
Code: [Select]
/*
  MOD MULTI-LIGHTBOXES
  START INSERT
*/
//these settings can not be changed by the user, only by administrator from ACP
  if (isset($HTTP_POST_VARS['user_lightbox'])) unset($HTTP_POST_VARS['user_lightbox']);
  if (isset($HTTP_POST_VARS['user_lightbox_private'])) unset($HTTP_POST_VARS['user_lightbox_private']);
  if (isset($HTTP_POST_VARS['user_lightbox_count'])) unset($HTTP_POST_VARS['user_lightbox_count']);
/*
  MOD MULTI-LIGHTBOXES
  END INSERT
*/



Step 5
Open download.php
Find:
Code: [Select]
 if (empty($user_info['lightbox_image_ids']) || !function_exists("gzcompress") || !function_exists("crc32")) {Insert above:
Code: [Select]
/*
  MOD MULTI-LIGHTBOXES
  START INSERT
*/
  $lightbox_id = (isset($HTTP_POST_VARS['lightbox_id']) && $HTTP_POST_VARS['lightbox_id']) ? $HTTP_POST_VARS['lightbox_id'] : ((isset($HTTP_GET_VARS['lightbox_id']) && $HTTP_GET_VARS['lightbox_id']) ? $HTTP_GET_VARS['lightbox_id'] : 0);
  if ($lightbox_id)
  {
    $sql = "SELECT l.lightbox_id, l.lightbox_name, l.lightbox_private, l.lightbox_image_ids, l.user_id, u.user_name, u.user_lightbox_private
            FROM ".LIGHTBOXES_TABLE." l
            LEFT JOIN ".USERS_TABLE." u ON u.user_id = l.user_id
            WHERE l.lightbox_id = '".$lightbox_id."'";
    $row = $site_db->query_firstrow($sql);
    $user_info['lightbox_image_ids'] = (!$row['lightbox_private'] && $row['user_lightbox_private'] && $config['lightbox_share'] || $user_info['user_level'] == ADMIN ) ? $row['lightbox_image_ids'] : "";//$user_info['lightbox_image_ids'];
  }
/*
  MOD MULTI-LIGHTBOXES
  END INSERT
*/


Step 6
Open includes/functions.php
Find:
Code: [Select]
 $sql = "UPDATE ".LIGHTBOXES_TABLE."
          SET lightbox_lastaction = ".$user_info['lightbox_lastaction'].", lightbox_image_ids = '".$user_info['lightbox_image_ids']."'
          WHERE user_id = ".$user_info['user_id'];
  return ($site_db->query($sql)) ? 1 : 0;
(there are two instances of this block of code, you must do changes from this step only on find the first instance! This block located inside add_to_lightbox function)
Replace with:
Code: [Select]
/*
  MOD MULTI-LIGHTBOXES
  START REPLACE
*/
  $sql = "UPDATE ".LIGHTBOXES_TABLE."
          SET lightbox_lastaction = ".$user_info['lightbox_lastaction'].", lightbox_image_ids = '".$user_info['lightbox_image_ids']."'
          WHERE user_id = ".$user_info['user_id']." AND id = ".$user_info['user_lightbox'];
  if ($site_db->query($sql))
  {
    $user_info['lightboxes'][$user_info['user_lightbox']]['count']++;
    $user_info['lightboxes_list'][$user_info['user_lightbox']] = lightbox_trim($user_info['lightboxes'][$user_info['user_lightbox']]['name'])." (".$user_info['lightboxes'][$user_info['user_lightbox']]['count'].")";
    return true;
  }
  return false;
/*
  MOD MULTI-LIGHTBOXES
  END REPLACE
*/


Step 6.1
Find:
Code: [Select]
 $sql = "UPDATE ".LIGHTBOXES_TABLE."
          SET lightbox_lastaction = ".$user_info['lightbox_lastaction'].", lightbox_image_ids = '".$user_info['lightbox_image_ids']."'
          WHERE user_id = ".$user_info['user_id'];
  return ($site_db->query($sql)) ? 1 : 0;
(yes, this is the exact same block as in previous step, but this is second instance! This block located inside remove_from_lightbox function)
Replace with:
Code: [Select]
/*
  MOD MULTI-LIGHTBOXES
  START REPLACE
*/
  $sql = "UPDATE ".LIGHTBOXES_TABLE."
          SET lightbox_lastaction = ".$user_info['lightbox_lastaction'].", lightbox_image_ids = '".$user_info['lightbox_image_ids']."'
          WHERE user_id = ".$user_info['user_id']." AND id = ".$user_info['user_lightbox'];
  if ($site_db->query($sql)) {
    $user_info['lightboxes'][$user_info['user_lightbox']]['count']--;
    $user_info['lightboxes_list'][$user_info['user_lightbox']] = lightbox_trim($user_info['lightboxes'][$user_info['user_lightbox']]['name'])." (".$user_info['lightboxes'][$user_info['user_lightbox']]['count'].")";
    return true;
  }
  return false;
/*
  MOD MULTI-LIGHTBOXES
  END REPLACE
*/

Step 6.2
Find:
Code: [Select]
 $sql = "UPDATE ".LIGHTBOXES_TABLE."
          SET lightbox_image_ids = '', lightbox_lastaction = $current_time
          WHERE user_id = ".$user_info['user_id'];
  if ($site_db->query($sql)) {
Replace with:
Code: [Select]
/*
  MOD MULTI-LIGHTBOXES
  START REPLACE
*/
  $sql = "UPDATE ".LIGHTBOXES_TABLE."
          SET lightbox_lastaction = ".$current_time.", lightbox_image_ids = ''
          WHERE user_id = ".$user_info['user_id']." AND id = ".$user_info['user_lightbox'];
  if ($site_db->query($sql)) {
    $user_info['lightboxes'][$user_info['user_lightbox']]['count'] = 0;
    $user_info['lightboxes_list'][$user_info['user_lightbox']] = lightbox_trim($user_info['lightboxes'][$user_info['user_lightbox']]['name'])." (0)";
/*
  MOD MULTI-LIGHTBOXES
  END REPLACE
*/


Step 6.3
At the end of the file, above closing ?> insert:
Code: [Select]
/*
  MOD MULTI-LIGHTBOXES
  START INSERT
*/function lightbox_trim($name)
{
  $max = 10;
  if (strlen($name) > $max)
  {
    $name = substr($name, 0, $max)."...";
  }
  return $name;
}
function fixhtml($text, $quote = 1, $amp = 0)
{
  if ($amp) $text = str_replace("&", "&amp;", $text);
  if ($quote) $text = str_replace("\"", "&quot;", $text);
  $text = str_replace("<", "&lt;", str_replace(">", "&gt;", $text));
  return $text;
}
/*
  MOD MULTI-LIGHTBOXES
  END INSERT
*/


Step 6.4
If you have PM v2 mod installed, skip this step and continue to Step 7
Otherwise at the end of the file, above closing ?> insert:
Code: [Select]
/*
  MOD MULTI-LIGHTBOXES
  START INSERT
*/
function get_msg($msg) {
  $txt = "";
  if (is_array($msg)) {
    $error = implode($msg['error'], "<br />");
    $good = implode($msg['good'], "<br />");
    $plain = implode($msg['plain'], "<br />");
  }
  else {
    $error = $msg;
  }
  if ($error) {
    $txt = "<div class=\"msg_error\">".$error."</div>";
  }
  if ($good) {
    $txt .= "<div class=\"msg_good\">".$good."</div>";
  }
  if ($plain) {
    $txt .= "<div class=\"msg_plain\">".$plain."</div>";
  }
  return $txt;
}
/*
  MOD MULTI-LIGHTBOXES
  END INSERT
*/



Step 7
Open includes/page_header.php
Find:
Code: [Select]
   $msg = (add_to_lightbox($id)) ? $lang['lightbox_add_success'] : $lang['lightbox_add_error'];Replace with:
Code: [Select]
/*
  MOD MULTI-LIGHTBOXES
  START REPLACE
*/
    $msg = (add_to_lightbox($id)) ? preg_replace("/".$site_template->start."name".$site_template->end."/iU", $user_info['lightboxes'][$user_info['user_lightbox']]['name'], $lang['lightbox_add_success']) : preg_replace("/".$site_template->start."name".$site_template->end."/iU", $user_info['lightboxes'][$user_info['user_lightbox']]['name'], $lang['lightbox_add_error']);
/*
  MOD MULTI-LIGHTBOXES
  END REPLACE
*/


Step 7.1
Find:
Code: [Select]
   $msg = (remove_from_lightbox($id)) ? $lang['lightbox_remove_success'] : $lang['lightbox_remove_error'];Replace with:
Code: [Select]
/*
  MOD MULTI-LIGHTBOXES
  START REPLACE
*/
    $msg = (remove_from_lightbox($id)) ? preg_replace("/".$site_template->start."name".$site_template->end."/iU", $user_info['lightboxes'][$user_info['user_lightbox']]['name'], $lang['lightbox_remove_success']) : preg_replace("/".$site_template->start."name".$site_template->end."/iU", $user_info['lightboxes'][$user_info['user_lightbox']]['name'], $lang['lightbox_remove_error']);
/*
  MOD MULTI-LIGHTBOXES
  END REPLACE
*/


Step 7.2
Find:
Code: [Select]
   $msg = (clear_lightbox()) ? $lang['lightbox_delete_success'] : $lang['lightbox_delete_error'];Replace with:
Code: [Select]
/*
  MOD MULTI-LIGHTBOXES
  START REPLACE
*/
    $msg = (clear_lightbox()) ? preg_replace("/".$site_template->start."name".$site_template->end."/iU", $user_info['lightboxes'][$user_info['user_lightbox']]['name'], $lang['lightbox_clear_success']) : preg_replace("/".$site_template->start."name".$site_template->end."/iU", $user_info['lightboxes'][$user_info['user_lightbox']]['name'], $lang['lightbox_clear_error']);
/*
  MOD MULTI-LIGHTBOXES
  END REPLACE
*/

Step 7.3
Find:
Code: [Select]
//-----------------------------------------------------
//--- Save Rating -------------------------------------
//-----------------------------------------------------
Insert above:
Code: [Select]
/*
  MOD MULTI-LIGHTBOXES
  START INSERT
*/
//-----------------------------------------------------
//--- Multi-Lightboxes ---------------------------------
//-----------------------------------------------------
if ($user_info['user_level'] >= USER && $config['lightbox_count'])
{
  $user_lightbox_dropdown = (count($user_info['lightboxes_list']) > 1) ? get_dropdown_options("user_lightbox", $user_info['lightboxes_list'], $user_info['user_lightbox'], 1, 0, 1, 0, "", "lightboxidropdown") : "";
}
else
{
  $user_lightbox_dropdown = "";
}
$site_template->register_vars(array(
  "user_lightbox_dropdown" => $user_lightbox_dropdown,
  "lang_lightbox_select" => $lang['lightbox_select'],
));
$user_lightbox_dropdown = ($user_lightbox_dropdown) ? $site_template->parse_template("lightbox_dropdown") : "";
$site_template->register_vars("user_lightbox_form", $user_lightbox_dropdown);
/*
  MOD MULTI-LIGHTBOXES
  END INSERT
*/



Continue next reply
« Last Edit: September 21, 2011, 01:48:44 AM by V@no »
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Multi-Lightboxes v1.03.1
« Reply #1 on: December 03, 2005, 06:22:52 AM »
Step 8
Open includes/sessions.php
Find:
Code: [Select]
   if ($user_id != GUEST) {
      $sql = "SELECT u.*, l.*
              FROM ".USERS_TABLE." u, ".LIGHTBOXES_TABLE." l
              WHERE ".get_user_table_field("u.", "user_id")." = $user_id AND l.user_id = ".get_user_table_field("u.", "user_id");
      $user_info = $site_db->query_firstrow($sql);
      if (!$user_info) {
        $sql = "SELECT *
                FROM ".USERS_TABLE."
                WHERE ".get_user_table_field("", "user_id")." = $user_id";
        $user_info = $site_db->query_firstrow($sql);
        if ($user_info) {
          $lightbox_id = get_random_key(LIGHTBOXES_TABLE, "lightbox_id");
          $sql = "INSERT INTO ".LIGHTBOXES_TABLE."
                  (lightbox_id, user_id, lightbox_lastaction, lightbox_image_ids)
                  VALUES
                  ('$lightbox_id', ".$user_info[$user_table_fields['user_id']].", $this->current_time, '')";
          $site_db->query($sql);
          $user_info['lightbox_lastaction'] = $this->current_time;
          $user_info['lightbox_image_ids'] = "";
        }
      }
    }
(this block is located inside load_user_info function. MAKE SURE YOU MATCH THE BRACKETS!)
Replace with:
Code: [Select]
/*
  MOD MULTI-LIGHTBOXES
  START REPLACE
*/
    if ($user_id != GUEST)
    {
      $sql = "SELECT *
              FROM ".USERS_TABLE."
              WHERE ".get_user_table_field("", "user_id")." = ".$user_id;
      $user_info = $site_db->query_firstrow($sql);
      if (!$user_info['user_id'])
      {
        $this->logout($user_id);
        $user_id = GUEST;
      }
    }
    if ($user_id != GUEST)
    {
      $i = 0;
      $delete = "";
      $update = 0;
      $correct = 0;
      $ids = "";
      $limit = ($user_info['user_lightbox_count'] == -1 || !$config['lightbox_count'] || $user_info['user_level'] == ADMIN) ? -1 : (($user_info['user_lightbox_count']) ? $user_info['user_lightbox_count'] : $config['lightbox_count']);
      global $HTTP_POST_VARS, $HTTP_GET_VARS;
      if (isset($HTTP_POST_VARS['user_lightbox']) && $HTTP_POST_VARS['user_lightbox'])
      {
        $user_info['user_lightbox'] = $HTTP_POST_VARS['user_lightbox'];
        $update = 1;
      }
      elseif (isset($HTTP_GET_VARS['user_lightbox']) && $HTTP_GET_VARS['user_lightbox'])
      {
        $user_info['user_lightbox'] = $HTTP_GET_VARS['user_lightbox'];
        $update = 1;
      }

      $sql = "SELECT lightbox_id, lightbox_name, lightbox_image_ids, lightbox_private, id, lightbox_lastaction, IF(id = ".$user_info['user_lightbox'].", id, 0) AS num
              FROM ".LIGHTBOXES_TABLE."
              WHERE user_id = ".$user_id."
              ORDER BY id ASC";
      $row = $site_db->query($sql);
      while ($result = $site_db->fetch_array($row))
      {
        $i++;
        if ($limit != -1 && $i > $limit)
        {
          $delete .= (($delete) ? "," : "").$result['id'];
        }
        else
        {
          $user_info['lightboxes'][$result['id']]['name'] = $result['lightbox_name'];
          $user_info['lightboxes'][$result['id']]['private'] = $result['lightbox_private'];
          $user_info['lightboxes'][$result['id']]['lightbox_id'] = $result['lightbox_id'];
          $user_info['lightboxes'][$result['id']]['id'] = $result['id'];
          $user_info['lightboxes'][$result['id']]['image_ids'] = $result['lightbox_image_ids'];
          $user_info['lightboxes'][$result['id']]['lastaction'] = $result['lightbox_lastaction'];
          $user_info['lightboxes'][$result['id']]['count'] = (trim($result['lightbox_image_ids'])) ? count(explode(" ", trim($result['lightbox_image_ids']))) : 0;
          $user_info['lightboxes_list'][$result['id']] = fixhtml(lightbox_trim($result['lightbox_name'])." (".$user_info['lightboxes'][$result['id']]['count'].")");
          if ($i == 1)
          {
            $first = $result['id'];
            $ids = $result['lightbox_image_ids'];
            $lastaction = $result['lightbox_lastaction'];
          }
          if ($result['num'])
          {
            $correct = 1;
            $user_info['lightbox_image_ids'] = $result['lightbox_image_ids'];
            $user_info['lightbox_lastaction'] = $result['lightbox_lastaction'];
          }
        }
      }
      if (!$correct)
      {
        $user_info['user_lightbox'] = $first;
        $user_info['lightbox_image_ids'] = $ids;
        $user_info['lightbox_lastaction'] = $lastaction;
        $update = 1;
      }
      if ($delete)
      {
        $sql = "DELETE FROM ".LIGHTBOXES_TABLE." WHERE id IN (".$delete.")";
        $site_db->query($sql);
      }
      if ($user_info && !$user_info['user_lightbox'])
      {
        $lightbox_id = get_random_key(LIGHTBOXES_TABLE, "lightbox_id");
        $sql = "INSERT INTO ".LIGHTBOXES_TABLE."
                (lightbox_id, user_id, lightbox_lastaction)
                VALUES
                ('$lightbox_id', ".$user_id.", $this->current_time)";
        $site_db->query($sql);
        $user_info['lightbox_lastaction'] = $this->current_time;
        $user_info['lightbox_image_ids'] = "";
        $user_info['user_lightbox'] = $site_db->get_insert_id();
        $update = 1;
      }
      if ($update)
      {
        $sql = "UPDATE ".USERS_TABLE." SET user_lightbox = ".$user_info['user_lightbox']." WHERE user_id = ".$user_id;
        $site_db->query($sql);
      }
    }
/*
  MOD MULTI-LIGHTBOXES
  END REPLACE
*/

Step 8.1
Find:
Code: [Select]
     $user_info['user_lastvisit'] = ($this->read_cookie_data("lastvisit")) ? $this->read_cookie_data("lastvisit") : $this->current_time;Insert below:
Code: [Select]
/*
  MOD MULTI-LIGHTBOXES
  START INSERT
*/
      $user_info['user_lightbox'] = 0;
      $user_info['lightboxes'] = array();
      $user_info['lightboxes_list'] = array();
/*
  MOD MULTI-LIGHTBOXES
  END INSERT
*/



Step 9
Open includes/db_field_definitions.php
At the end, above closing ?> insert:
Code: [Select]
/*
  MOD MULTI-LIGHTBOXES
  START INSERT
*/
$additional_user_fields['user_lightbox_count'] = array($lang['user_lightbox_count'], "text", 0);
$additional_user_fields['user_lightbox_private'] = array($lang['user_lightbox_private'], "radio", 0);
/*
  MOD MULTI-LIGHTBOXES
  END INSERT
*/



Step 10
Open admin/settings.php
Find the last instance of show_table_separator($setting_group[XX], 2, "#setting_group_XX"); line, where XX is a number. Now, add 1 to that number and write down somewhere the result, you will need this number for next two steps! (EXAMPLE: in fresh 4images the last instance of this line looks like this: show_table_separator($setting_group[7], 2, "#setting_group_[color]7[/color]"); number 7 is what we are looking for. Then 7 + 1 = 8;   8 - is the number we must remmember for next steps[/i])


Step 10.1
Find:
Code: [Select]
 show_form_footer($lang['save_changes'], "", 2);Insert above 4images 1.7-1.7.1:
Code: [Select]
/*
  MOD MULTI-LIGHTBOXES
  START INSERT
*/
  show_table_separator($setting_group[XX], 2, "#setting_group_XX");
  show_setting_row("lightbox_count");
  show_setting_row("lightbox_share", "radio");
/*
  MOD MULTI-LIGHTBOXES
  END INSERT
*/

Insert above 4images 1.7.2 or newer:
Code: [Select]
/*
  MOD MULTI-LIGHTBOXES
  START INSERT
*/
  show_table_separator($setting_group[XX], 2, "setting_group_XX");
  show_setting_row("lightbox_count");
  show_setting_row("lightbox_share", "radio");
/*
  MOD MULTI-LIGHTBOXES
  END INSERT
*/

Replace XX with the number from Step 10



Step 11
Open lang/<your language>/admin.php
At the end, above closing ?> insert:
Code: [Select]
/*
  MOD MULTI-LIGHTBOXES
  START INSERT
*/
/*-- Setting-Group XX--*/
$setting_group[XX]="Multi-lightboxes";
$setting["lightbox_count"] = "Number of allowed lightboxes";
$setting["lightbox_share"] = "Allow share lightboxes";
/*
  MOD MULTI-LIGHTBOXES
  END INSERT
*/
Replace XX with the number from Step 10



Step 12
Open lang/<your language>/main.php
At the end, above closing ?> insert:
Code: [Select]
/*
  MOD MULTI-LIGHTBOXES
  START INSERT
*/
$lang['lightbox_no_images'] = "No images stored in this lightbox.";
$lang['lightbox_add_success'] = "Image added in <i>{name}</i> lightbox.";
$lang['lightbox_add_error'] = "Error adding image into <i>{name}</i> lightbox!";
$lang['lightbox_remove_success'] = "Image deleted from <i>{name}</i> lightbox.";
$lang['lightbox_remove_error'] = "Error deleting image from <i>{name}</i> lightbox!";
$lang['lang_delete'] = "Delete";
$lang['private'] = "Private";
$lang['clear'] = "Clear";
$lang['add_new'] = "Add new";
$lang['lightbox_manage'] = "Manage lightboxes";
$lang['delete_lightbox'] = "Clear <i>{name}</i> lightbox";
$lang['lightbox_clear_success'] = "Lightbox <i>{name}</i> emptied";
$lang['lightbox_clear_error'] = "Error cleaning <i>{name}</i> lightbox!";
$lang['clear_lightbox_confirm'] = "Do you really want to delete all images from {name} lightbox?";
$lang['lightbox_update_success'] = "Lightbox <i>{name}</i> updated";
$lang['lightbox_update_error'] = "<i>{name}</i> lightbox was not updated";
$lang['mlightbox_delete_success'] = "Lightbox <i>{name}</i> deleted";
$lang['mlightbox_delete_error'] = "<i>{name}</i> lightbox was not deleted";
$lang['lightbox_name_error'] = "Please check name of marked {lightbox}";
$lang['lightbox_single'] = "lightbox";
$lang['lightbox_plural'] = "lightboxes";
$lang['noname'] = "no name";
$lang['lightbox_create_success'] = "Added <i>{name}</i> lightbox";
$lang['lightbox_create_error'] = "Error adding <i>{name}</i> lightbox!";
$lang['user_lightbox'] = "Shared lightboxes:";
$lang['lightbox_settings'] = "Settings";
$lang['lightbox_limit'] = "You have {total} of {limit} avalable lightboxes";
$lang['lightbox_unlimited'] = "You can add unlimited number of lightboxes";
$lang['user_lightbox_count'] = "Number of allowed lightboxes<br /><span class=\"smalltext\"><b><font color=\"red\">0</font></b> - use global settings<br /><b><font color=\"red\">-1</font></b> - unlimited</span>";
$lang['user_lightbox_private'] = "Allow share lightboxes";
$lang['lightbox_select'] = "Go";
/*
  MOD MULTI-LIGHTBOXES
  END INSERT
*/



Step 13
If you have not installed [MOD] Dropdown options for custom database fields yet, please do now, atleast do the Step 3
If you have installed it, please redo Step 3 again. I just updated it with a little bug fix regarding custom style class being ignored (it will not affect any code that used that mod)



Step 14
The following steps are template-related, so I'll just give information what you need to add, the design is your task ;)

Open templates/<your template>/lightbox.html
Insert:
Code: [Select]
{if url_lightbox_manage}
<a href="{url_lightbox_manage}"><b>{lang_lightbox_manage}</b></a>
{endif url_lightbox_manage}
Also, you can use the following conditional tags:
Quote
{if lightbox_notin_manage}
block that you DONT want to show on "lightbox manager" page
{endif lightbox_notin_manage}
And
Quote
{if lightbox_in_manage}
block that you want to show ONLY on "lightbox manager" page
{endif lightbox_in_manage}



Step 15
Open templates/<your template>/member_profile.html
Insert
Code: [Select]
{if user_lightbox}
        <tr>
          <td class="row1"><b>{lang_user_lightbox}</b></td>
          <td class="row1">{user_lightbox}</td>
        </tr>
{endif user_lightbox}



Step 16
Open templates/<your template>/user_logininfo.html (or any other template where you want to display lightboxes dropdown menu)
Insert:
Code: [Select]
{if user_lightbox_form}{user_lightbox_form}{endif user_lightbox_form}


Step 17
Open templates/<your template>/style.css
Insert:
Code: [Select]
.mlightbox0 {
  background-color: #FFCECE;
  color: #2F6B9D;
  font-weight: bold;
}
.mlightbox1 {
  background-color: #CEFFDD;
  color: #2F6B9D;
  font-weight: bold;
}
.msg_good {
  background-color: #CEFFDD;
  font-weight: bold;
border: 1px solid #5E6C80;
padding: 3px 3px 3px 3px ;
margin: 3px 0px 3px 0px ;
}

.msg_error {
  background-color: #FFCECE;
  font-weight: bold;
border: 1px solid #5E6C80;
padding: 3px 3px 3px 3px ;
margin: 3px 0px 3px 0px ;
}

.msg_plain {
  background-color: transparent;
  font-weight: bold;
border: 1px solid #5E6C80;
padding: 3px 3px 3px 3px ;
margin: 3px 0px 3px 0px ;
}
.lightboxinput {
  font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif;
  color: #0f5475;
  font-size: 11px;
  width: 170px;
}
.lightboxinputnew {
  font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif;
  color: #0f5475;
  font-size: 11px;
  width: 125px;
}
.lightboxidropdown {
  font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif;
  color: #0f5475;
  font-size: 11px;
  width: 95px;
}
.lightboxibutton {
  font-family:  Tahoma,Verdana,Arial, Helvetica, sans-serif;
  background-color: #003366;
  color: #fcdc43;
  font-size: 11px;
  font-weight: bold;
  width: 27px;
}



Step 18
Open admin/images.php[/b]
Find:
Code: [Select]
 $sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_media_file, i.image_thumb_file, l.lightbox_image_ids
Replace with:
Code: [Select]
 $sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_media_file, i.image_thumb_file, l.lightbox_image_ids, l.lightbox_id
Step 18.1
Find:
Code: [Select]
             WHERE user_id = ".$image_row['user_id'];
Replace with:
Code: [Select]
              WHERE lightbox_id = '".$image_row['lightbox_id']."'";


---------- [ Troubleshooting / info ] -----------

- If you see some condition tags when you open lightbox page (or any other) (i.e. {if url_lightbox_manage}{endif url_lightbox_manage} ) Most probably you did not apply this or/end this fix yet.
- The maximum lightbox name lenght is 32 letters, there is no warning if name is longer, it will automaticaly cut to 32 letters. If you want change that limit, you will need manualy run this MySQL query:
Code: [Select]
ALTER TABLE `4images_lightboxes` CHANGE `lightbox_name` `lightbox_name` VARCHAR( XX )  NOT NULL where XX is the limit number
- The maximum lightbox name lenght in dropdown is set to 10, you can adjust it in includes/functions.php
Code: [Select]
 $max = 10;- in v1 the only way add an image to another lightbox is to select the needed lightbox from dropdown before adding image (the page must refresh!).
- In lightbox manager page the number next to lightbox name field represent number of images in the lightbox
- members can see shared lightboxes from member's profile page
- admin can see even not shared lightboxes. At members profile page the shared lightboxes marked with + while not shared marked with -
« Last Edit: November 22, 2010, 05:25:56 AM by V@no »
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Multi-Lightboxes v1.03.1
« Reply #2 on: December 03, 2005, 06:27:13 AM »
--------------- [ Version history ] ---------------

1.03.2- fixed misspelled variable in step 6.3
1.03.1- fixed lightboxes being overwritten when an image deleted (added Steps 18.x)
1.03 - changed Step 2.1 (more info here)
1.02 - fixed apostrophe and quotes in lightbox names issue (redo Step 2.1, 6.3 and 8 )
- in Step 12 fixed "clear lightbox" missing strings
1.01 - fixed MySQL query
1.0 - Initial release

« Last Edit: September 21, 2011, 01:49:27 AM by V@no »
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline JensF

  • Addicted member
  • ******
  • Posts: 1.028
    • View Profile
    • http://www.terraristik-galerie.de
Re: [MOD] Multi-Lightboxes v1.03.1
« Reply #3 on: December 03, 2005, 11:25:06 AM »
Hi,

no problem with delete the posts.

but i have one problem with this mod :) . i have install this one -> http://www.4homepages.de/forum/index.php?topic=9288.0

and now i can´t made the changes in step 2.5b

can you help me with this?

and now in step 7.1 & 7.2 there are two instances of this line. change both???

and in step 3.5 i dpn´t have this line

Code: [Select]
$page_url .= ($lightbox_id) ? (($page_url) ? "&" : "?")."lightbox_id=".$lightbox_id : "";
Mit freundlichem Gruß
Jens Funk



-> Sorry for my bad English <-

Offline Loda

  • Sr. Member
  • ****
  • Posts: 353
    • View Profile
    • Fotosucht Schweiz
Re: [MOD] Multi-Lightboxes v1.03.1
« Reply #4 on: December 03, 2005, 03:07:26 PM »
no problem, v@no!
my post was:
it works! (version 1.7) you are the best!

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Multi-Lightboxes v1.03.1
« Reply #5 on: December 03, 2005, 06:31:13 PM »
but i have one problem with this mod :) . i have install this one -> http://www.4homepages.de/forum/index.php?topic=9288.0

and now i canґt made the changes in step 2.5b
I've added Step 2.5c (not tested it though)


and now in step 7.1 & 7.2 there are two instances of this line. change both???
Can't be.
There are simular lines, actualy 3 instances with simular code, one for add to lightbox, second for remove and third for deleting entire lightbox.

and in step 3.5 i dpnґt have this line

Code: [Select]
$page_url .= ($lightbox_id) ? (($page_url) ? "&" : "?")."lightbox_id=".$lightbox_id : "";
Ouch...I've added this line in the wrong place, thats one of the replacement lines, not seeking...updated it.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline JensF

  • Addicted member
  • ******
  • Posts: 1.028
    • View Profile
    • http://www.terraristik-galerie.de
Re: [MOD] Multi-Lightboxes v1.03.1
« Reply #6 on: December 05, 2005, 01:23:50 PM »
Hi,

i have played with the multi lightbox at v@nos site and i have a question.

When i have a pic in album1 but i want it in album2. is there a way to move the pic from album1 to album2 ????
Mit freundlichem Gruß
Jens Funk



-> Sorry for my bad English <-

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Multi-Lightboxes v1.03.1
« Reply #7 on: December 05, 2005, 02:43:31 PM »
only manualy removing it from one lightbox, then switching lighbox and adding it to another one.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline JensF

  • Addicted member
  • ******
  • Posts: 1.028
    • View Profile
    • http://www.terraristik-galerie.de
Re: [MOD] Multi-Lightboxes v1.03.1
« Reply #8 on: December 05, 2005, 03:58:25 PM »
Thanks,

now i have installed it into my galery and i thing it works perfect.....
Mit freundlichem Gruß
Jens Funk



-> Sorry for my bad English <-

Offline JensF

  • Addicted member
  • ******
  • Posts: 1.028
    • View Profile
    • http://www.terraristik-galerie.de
Re: [MOD] Multi-Lightboxes v1.03.1
« Reply #9 on: December 05, 2005, 07:48:33 PM »
Hi,

i found a problem. After the installation the PM function is not working. I have blank page when i go the PM and will write some....Has any other this problem, too??
Mit freundlichem Gruß
Jens Funk



-> Sorry for my bad English <-

Offline Loda

  • Sr. Member
  • ****
  • Posts: 353
    • View Profile
    • Fotosucht Schweiz
Re: [MOD] Multi-Lightboxes v1.03.1
« Reply #10 on: December 05, 2005, 08:26:04 PM »
Quote
Has any other this problem, too??
yes, you're right, i have this problem, too!

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Multi-Lightboxes v1.03.1
« Reply #11 on: December 06, 2005, 12:30:51 AM »
Oh, right, forgot that I've used the same function for colored type messages in PM mod...in includes/functions.php remove
Code: [Select]
function get_msg($msg) {
  $txt = "";
  if (is_array($msg)) {
    $error = implode($msg['error'], "<br />");
    $good = implode($msg['good'], "<br />");
    $plain = implode($msg['plain'], "<br />");
  }
  else {
    $error = $msg;
  }
  if ($error) {
    $txt = "<div class=\"msg_error\">".$error."</div>";
  }
  if ($good) {
    $txt .= "<div class=\"msg_good\">".$good."</div>";
  }
  if ($plain) {
    $txt .= "<div class=\"msg_plain\">".$plain."</div>";
  }
  return $txt;
}
You should already have this function from PM mod.

I've updated the tutorial and split step 6.3.

P.S. just out of curiosity how much time did i take for you to install it?
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Stoleti

  • Hero Member
  • *****
  • Posts: 574
    • View Profile
Re: [MOD] Multi-Lightboxes v1.03.1
« Reply #12 on: December 06, 2005, 01:34:10 AM »
why when we give a album name with ' (i.e :  My Fav's  ) this show after "My Fav/'s" with "/" , this is the same of when we post html codes in profile , and we re-save again ....show ton's of "/"  8O

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Multi-Lightboxes v1.03.1
« Reply #13 on: December 06, 2005, 04:31:26 AM »
You are right (exept its \ not / ;))
I think I've fixed it. Redo Step 2.1, 6.3 and 8
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline JensF

  • Addicted member
  • ******
  • Posts: 1.028
    • View Profile
    • http://www.terraristik-galerie.de
Re: [MOD] Multi-Lightboxes v1.03.1
« Reply #14 on: December 06, 2005, 06:51:55 AM »
Oh, right, forgot that I've used the same function for colored type messages in PM mod...in includes/functions.php remove
Code: [Select]
function get_msg($msg) {
  $txt = "";
  if (is_array($msg)) {
    $error = implode($msg['error'], "<br />");
    $good = implode($msg['good'], "<br />");
    $plain = implode($msg['plain'], "<br />");
  }
  else {
    $error = $msg;
  }
  if ($error) {
    $txt = "<div class=\"msg_error\">".$error."</div>";
  }
  if ($good) {
    $txt .= "<div class=\"msg_good\">".$good."</div>";
  }
  if ($plain) {
    $txt .= "<div class=\"msg_plain\">".$plain."</div>";
  }
  return $txt;
}
You should already have this function from PM mod.

I've updated the tutorial and split step 6.3.

P.S. just out of curiosity how much time did i take for you to install it?

Hi,

i have do this but now i become a blank page when i will edit or create a lightbox. he do what i will (create a lightbox) but he brings me a blank page :(
Mit freundlichem Gruß
Jens Funk



-> Sorry for my bad English <-