Hi!
Here in the Forum there are several Versions to publish the Lightbox, that's my Version.
With this Modification, can Members their Lightbox publish for Members only or Members and Guests.
Demo: Access to the shared Lightbox is over the User Profil (see the link in the Lightbox row)1.) copy the "install_lightbox_publish.php" from the attachment in your Galery root and call it on.
2.) search in includes/db_field_definitions.php "?>" and insert above:
//########################### Start Lightbox publish ################################################
$additional_user_fields['user_lightbox_publish'] = array($lang['user_lightbox_publish'], "radio", 0);
$additional_user_fields['user_lightbox_guest'] = array($lang['user_lightbox_guest'], "radio", 0);
//########################### End Lightbox publish ##################################################
3.) search in includes/functions.php in "function get_user_info":
$sql = "SELECT *
FROM ".USERS_TABLE."
WHERE ".get_user_table_field("", "user_id")." = $user_id";
and replace:
//##################### Start Lightbox publish #####################
// Show in function get_user_info
/* $sql = "SELECT *
FROM ".USERS_TABLE."
WHERE ".get_user_table_field("", "user_id")." = $user_id"; */
//##################### End Lightbox publish #######################
$sql = "SELECT u.*,l.*
FROM ".USERS_TABLE." u
LEFT JOIN ".LIGHTBOXES_TABLE." l ON (l.user_id = u.user_id)
WHERE ".get_user_table_field("u.", "user_id")." = $user_id";
4.) search in lang/yourLang/main.php "?>" and insert above:
(deutsch)
//##################### Start Lightbox publish #####################
$lang['user_lightbox_guest'] = "Leuchtkasten auch für Gäste veröffentlichen:<br><span class=\"smalltext\"> \"Nein\" nur für Mitglieder</span>";
$lang['user_lightbox_publish'] = "Leuchtkasten veröffentlichen:";
$lang['user_lightbox_publish_from'] = "Leuchtkasten von {user_name}";
$lang['user_lightbox_count'] = "{count_lightbox_images} Bilder im Leuchtkasten";
//##################### End Lightbox publish #####################
(english)
//##################### Start Lightbox publish #####################
$lang['user_lightbox_guest'] = "Lightbox for guests publish:<br><span class=\"smalltext\"> \"No\" for Members only</span>";
$lang['user_lightbox_publish'] = "Lightbox publish:";
$lang['user_lightbox_publish_from'] = "Lightbox from {user_name}";
$lang['user_lightbox_count'] = "{count_lightbox_images} Images in Lightbox";
//##################### End Lightbox publish #####################
5.) create a new file, call it "lightbox_publish.php" and store it in your Galery/root with following content:"
<?php
/**************************************************************************
* *
* 4images - A Web Based Image Gallery Management System *
* ---------------------------------------------------------------- *
* *
* File: lightbox_publish.php *
* Copyright: (C) 2002-2011 Jan Sorgalla *
* Email: jan@4homepages.de *
* Web: http://www.4homepages.de *
* Scriptversion: 1.7.10 *
* Fileversion: 1.0 by Rembrandt www.vienna-pictures.com *
* Never released without support from: Nicky (http://www.nicky.net) *
* *
**************************************************************************
* *
* Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz- *
* bedingungen (Lizenz.txt) für weitere Informationen. *
* --------------------------------------------------------------- *
* This script is NOT freeware! Please read the Copyright Notice *
* (Licence.txt) for further information. *
* *
*************************************************************************/
$templates_used = 'lightbox,thumbnail_bit';
$main_template = 'lightbox';
define('GET_CACHES', 1);
define('ROOT_PATH', './');
define('MAIN_SCRIPT', __FILE__);
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
$user_access = get_permission();
include(ROOT_PATH.'includes/page_header.php');
if (isset($HTTP_GET_VARS[URL_USER_ID]) || isset($HTTP_POST_VARS[URL_USER_ID])) {
$user_id = (isset($HTTP_GET_VARS[URL_USER_ID])) ? intval($HTTP_GET_VARS[URL_USER_ID]) : intval($HTTP_POST_VARS[URL_USER_ID]);
$user_row = get_user_info($user_id);
}
else {
$user_id = GUEST;
}
if($user_info['user_id']!= $user_row['user_id']){
if(empty($user_row['user_lightbox_publish'])){
show_error_page($lang['lightbox_register']);
}
if (empty($user_row['user_lightbox_guest']) && $user_info['user_level'] == GUEST || $user_info['user_level'] == USER_AWAITING) {
show_error_page($lang['lightbox_register']);
}
}
//-----------------------------------------------------
//--- Show Images -------------------------------------
//-----------------------------------------------------
$imgtable_width = ceil((intval($config['image_table_width'])) / $config['image_cells']);
if ((substr($config['image_table_width'], -1)) == "%") {
$imgtable_width .= "%";
}
$download_allowed = false;
$num_rows_all = 0;
$num_rows = 0;
if (!empty($user_row['lightbox_image_ids'])){
$image_id_sql = str_replace(" ", ", ", trim($user_row['lightbox_image_ids']));
$sql = "SELECT COUNT(image_id) AS images
FROM ".IMAGES_TABLE."
WHERE image_active = 1 AND image_id IN ($image_id_sql) AND cat_id NOT IN (".get_auth_cat_sql("auth_viewcat", "NOTIN").")";
$result = $site_db->query_firstrow($sql);
$num_rows_all = $result['images'];
}
$link_arg = $site_sess->url(ROOT_PATH."lightbox.php");
include(ROOT_PATH.'includes/paging.php');
$getpaging = new Paging($page, $perpage, $num_rows_all, $link_arg);
$offset = $getpaging->get_offset();
$site_template->register_vars(array(
"paging" => $getpaging->get_paging(),
"paging_stats" => $getpaging->get_paging_stats()
));
if ($num_rows_all) {
$sql = "SELECT COUNT(image_id) AS images
FROM ".IMAGES_TABLE."
WHERE image_active = 1 AND image_id IN ($image_id_sql) AND cat_id NOT IN (".get_auth_cat_sql("auth_download", "NOTIN").")";
$result = $site_db->query_firstrow($sql);
$download_allowed = intval($result['images']) > 0;
$additional_sql = "";
if (!empty($additional_image_fields)) {
foreach ($additional_image_fields as $key => $val) {
$additional_sql .= ", i.".$key;
}
}
$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_name")."
FROM (".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c)
LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
WHERE i.image_active = 1 AND i.image_id IN ($image_id_sql) AND c.cat_id = i.cat_id AND i.cat_id NOT IN (".get_auth_cat_sql("auth_viewcat", "NOTIN").")
ORDER BY i.".$config['image_order']." ".$config['image_sort'].", i.image_id ".$config['image_sort']."
LIMIT $offset, $perpage";
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);
}
if (!$num_rows) {
$thumbnails = "";
$msg .= ($msg != "") ? "<p>".$lang['lightbox_no_images'] : $lang['lightbox_no_images'];
}
else {
set_download_token($user_row['lightbox_image_ids']);
$thumbnails = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">\n";
$count = 0;
$bgcounter = 0;
while ($image_row = $site_db->fetch_array($result)) {
if (!$download_allowed && check_permission("auth_download", $image_row['cat_id'])) {
$download_allowed = true;
}
if ($count == 0) {
$row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
$thumbnails .= "<tr class=\"imagerow".$row_bg_number."\">\n";
}
$thumbnails .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";
$lightbox_publish = "lightbox_publish&user_id=".$user_row['user_id'];
show_image($image_row, $lightbox_publish);
$thumbnails .= $site_template->parse_template("thumbnail_bit");
$thumbnails .= "\n</td>\n";
$count++;
if ($count == $config['image_cells']) {
$thumbnails .= "</tr>\n";
$count = 0;
}
} // end while
if ($count > 0) {
$leftover = ($config['image_cells'] - $count);
if ($leftover >= 1) {
for ($i = 0; $i < $leftover; $i++){
$thumbnails .= "<td width=\"".$imgtable_width."\">\n \n</td>\n";
}
$thumbnails .= "</tr>\n";
}
}
$thumbnails .= "</table>\n";
} // end else
$lightbox_lastaction = format_date($config['date_format']." ".$config['time_format'], $user_row['lightbox_lastaction']);
if (empty($user_row['lightbox_lastaction'])) {
$lightbox_lastaction = "n/a";
}
$site_template->register_vars(array(
"thumbnails" => $thumbnails,
"lightbox_lastaction" => $lightbox_lastaction
));
unset($thumbnails);
//-----------------------------------------------------
//--- Clickstream -------------------------------------
//-----------------------------------------------------
$txt_clickstream = preg_replace("/".$site_template->start."user_name".$site_template->end."/siU", format_text($user_row['user_name'], 2), $lang['user_lightbox_publish_from']);
$clickstream = "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator'].$txt_clickstream."</span>";
//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$download_button = "";
if (function_exists("gzcompress") && function_exists("crc32")) {
if ($download_allowed && !empty($user_row['lightbox_image_ids'])) {
$download_button = "<a href=\"".$site_sess->url(ROOT_PATH."download.php?action=lightbox_publish&".URL_USER_ID."=".$user_row['user_id']."")."\"><img src=\"".get_gallery_image("download_zip.gif")."\" border=\"0\" alt=\"\" /></a>";
}
else {
$download_button = "<img src=\"".get_gallery_image("download_zip_off.gif")."\" border=\"0\" alt=\"\" />";
}
}
$site_template->register_vars(array(
"msg" => $msg,
"clickstream" => $clickstream,
"lang_lightbox" => $txt_clickstream,
"lang_lightbox_lastaction" => $lang['lighbox_lastaction'],
"download_button" => $download_button
));
$site_template->print_template($site_template->parse_template($main_template));
include(ROOT_PATH.'includes/page_footer.php');
?>
6.) search in details.php:
if ($mode == "lightbox") {
insert above:
//############### Start Lightbox publish ###################
if($mode == "lightbox_publish"){
if(isset($HTTP_GET_VARS[URL_USER_ID]) || isset($HTTP_POST_VARS[URL_USER_ID])) {
$user_id = (isset($HTTP_GET_VARS[URL_USER_ID])) ? intval($HTTP_GET_VARS[URL_USER_ID]) : intval($HTTP_POST_VARS[URL_USER_ID]);
if(!$user_id) {
show_error_page($lang['lightbox_register']);
}
$user_row = get_user_info($user_id);
}
if(!empty($user_row['lightbox_image_ids'])) {
$image_id_sql = str_replace(" ", ", ", trim($user_row['lightbox_image_ids']));
$sql = "SELECT image_id, cat_id, image_name, image_media_file, image_thumb_file
FROM ".IMAGES_TABLE."
WHERE image_active = 1 AND image_id IN ($image_id_sql) AND (cat_id NOT IN (".get_auth_cat_sql("auth_viewimage", "NOTIN").", ".get_auth_cat_sql("auth_viewcat", "NOTIN")."))
ORDER BY ".$config['image_order']." ".$config['image_sort'].", image_id ".$config['image_sort'];
$in_mode = 1;
}
}
//################ End Lightbox publish ####################
6.1) search:
$next_image_url = $site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$next_image_id.((!empty($mode)) ? "&mode=".$mode : ""));
insert below:
//########################### Start Lightbox publish ###########################################
$next_image_url =($mode == "lightbox_publish")? $next_image_url."&user_id=".$user_row['user_id'] : $next_image_url;
//########################### End Lightbox publish #############################################
6.2) search:
$prev_image_url = $site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$prev_image_id.((!empty($mode)) ? "&mode=".$mode : ""));
insert below:
//########################### Start Lightbox publish ###########################################
$prev_image_url =($mode == "lightbox_publish")? $prev_image_url."&user_id=".$user_row['user_id'] : $prev_image_url;
//########################### Start Lightbox publish ###########################################
6.3) search:
elseif ($mode == "search" && $in_mode) {
insert above:
//########################### Start Lightbox publish ###########################################
elseif ($mode == "lightbox_publish" && $in_mode) {
$page_url = "";
if (preg_match("/".URL_PAGE."=([0-9]+)/", $url, $regs)) {
if (!empty($regs[1]) && $regs[1] != 1) {
$page_url = "?".URL_PAGE."=".$regs[1];
}
}
$txt_clickstream = preg_replace("/".$site_template->start."user_name".$site_template->end."/siU", format_text($user_row['user_name'], 2), $lang['user_lightbox_publish_from']);
$clickstream .= "<a href=\"".$site_sess->url(ROOT_PATH."lightbox_publish.php?".$page_url."&".URL_USER_ID."=".$user_row['user_id']."")." \" class=\"clickstream\">".$txt_clickstream."</a>".$config['category_separator'];
}
//########################### END Lightbox publish #############################################
7.) search in download.php:
if ($result) {
and replace:
//########################### Start Lightbox publish ##############################################
}
if ($action == "lightbox_publish") {
if(isset($HTTP_GET_VARS[URL_USER_ID]) || isset($HTTP_POST_VARS[URL_USER_ID])) {
$user_id = (isset($HTTP_GET_VARS[URL_USER_ID])) ? intval($HTTP_GET_VARS[URL_USER_ID]) : intval($HTTP_POST_VARS[URL_USER_ID]);
if(!$user_id) {
show_error_page($lang['lightbox_register']);
}
}
if ($user_row = get_user_info($user_id)) {
if (empty($user_row['lightbox_image_ids']) || !function_exists("gzcompress") || !function_exists("crc32")) {
redirect("lightbox_publish.php");
}
}
if (!check_download_token($user_row['lightbox_image_ids'])) {
redirect("lightbox_publish.php");
}
$image_id_sql = str_replace(" ", ", ", trim($user_row['lightbox_image_ids']));
$image_ids = array();
$sql = "SELECT image_id, cat_id, image_media_file, image_download_url
FROM ".IMAGES_TABLE."
WHERE image_active = 1 AND image_id IN ($image_id_sql) AND cat_id NOT IN (".get_auth_cat_sql("auth_viewimage", "NOTIN").", ".get_auth_cat_sql("auth_viewcat", "NOTIN").", ".get_auth_cat_sql("auth_download", "NOTIN").")";
$result = $site_db->query($sql);
}
if ($result && ($action == "lightbox_publish") || ($action == "lightbox")) {
//########################### End Lightbox publish ##############################################
7.1) search:
redirect("lightbox.php?empty=1");
and replace:
//#################### Start Lightbox publish ################
if($action == "lightbox") {
redirect("lightbox.php?empty=1");
}
else{
redirect("lightbox_publish.php?empty=1");
//################### Start Lightbox publish #################
8.) search in member.php, section ($action == "showprofile"):
$site_template->register_vars(array(
"user_id" => $user_row['user_id'],
and replace:
//########################### Start Lightbox publish ###########################################
$lightbox_publish="";
if($user_info['user_id']!= $user_row['user_id']){
if(empty($user_row['user_lightbox_publish'])){
$lightbox_publish =1;
}
if (empty($user_row['user_lightbox_guest']) && $user_info['user_level'] == GUEST || $user_info['user_level'] == USER_AWAITING) {
$lightbox_publish =1;
}
}
$count_lightbox_images =(!empty($user_row['lightbox_image_ids']))? (count(explode(" ",$user_row['lightbox_image_ids']))):"";
$user_lightbox_count = preg_replace("/".$site_template->start."count_lightbox_images".$site_template->end."/siU", $count_lightbox_images, $lang['user_lightbox_count']);
$site_template->register_vars(array(
"lightbox_publish" => (!$lightbox_publish) ? "<a href=\"".$site_sess->url(ROOT_PATH."lightbox_publish.php?".URL_USER_ID."=".$user_row['user_id']."")." \">".$user_lightbox_count."</a>" :"",
//########################### End Lightbox publish ##############################################
// $site_template->register_vars(array(
"user_id" => $user_row['user_id'],
9.) search in templates/yourTemplates/member_profile.html:
<td class="row2">{if user_icq}<a href="http://www.icq.com/people/about_me.php?uin={user_icq}" target="_blank">{user_icq}</a> (<b>{user_icq_status}</b>){endif user_icq}</td>
</tr>
insert below:
{if lightbox_publish}
<tr>
<td class="row1"><b>{lang_lightbox}:</b></td>
<td class="row1">{lightbox_publish}</td>
</tr>
{endif lightbox_publish}
10.) search in templates/yourTemplates/member_editprofile.html:
<tr>
<td colspan="2" class="head1">{lang_optional_infos}</td>
insert above:
<tr>
<td class="row2"><b>{lang_user_lightbox_publish}</b></td>
<td class="row2">
<input type="radio" name="user_lightbox_publish" value="1"{user_lightbox_publish_yes}>
{lang_yes}
<input type="radio" name="user_lightbox_publish" value="0"{user_lightbox_publish_no}>
{lang_no}
</td>
</tr>
<tr>
<td class="row1"><b>{lang_user_lightbox_guest}</b></td>
<td class="row1">
<input type="radio" name="user_lightbox_guest" value="1"{user_lightbox_guest_yes}>
{lang_yes}
<input type="radio" name="user_lightbox_guest" value="0"{user_lightbox_guest_no}>
{lang_no}
</td>
</tr>
mfg Andi