Step 8Open
includes/sessions.phpFind:
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:
/*
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.1Find:
$user_info['user_lastvisit'] = ($this->read_cookie_data("lastvisit")) ? $this->read_cookie_data("lastvisit") : $this->current_time;
Insert
below:
/*
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 9Open
includes/db_field_definitions.phpAt the end,
above closing
?> insert:
/*
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 10Open
admin/settings.phpFind 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.1Find:
show_form_footer($lang['save_changes'], "", 2);
Insert
above 4images 1.7-1.7.1:
/*
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:
/*
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 11Open
lang/<your language>/admin.phpAt the end,
above closing
?> insert:
/*
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 12Open
lang/<your language>/main.phpAt the end,
above closing
?> insert:
/*
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 13If 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 14The 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.htmlInsert:
{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:
{if lightbox_notin_manage}
block that you DONT want to show on "lightbox manager" page
{endif lightbox_notin_manage}
And
{if lightbox_in_manage}
block that you want to show ONLY on "lightbox manager" page
{endif lightbox_in_manage}
Step 15Open
templates/<your template>/member_profile.htmlInsert
{if user_lightbox}
<tr>
<td class="row1"><b>{lang_user_lightbox}</b></td>
<td class="row1">{user_lightbox}</td>
</tr>
{endif user_lightbox}
Step 16Open
templates/<your template>/user_logininfo.html (or any other template where you want to display lightboxes dropdown menu)
Insert:
{if user_lightbox_form}{user_lightbox_form}{endif user_lightbox_form}
Step 17Open
templates/<your template>/style.cssInsert:
.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 18Open
admin/images.php[/b]
Find:
$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:
$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.1Find:
WHERE user_id = ".$image_row['user_id'];
Replace with:
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:
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 $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 -