Author Topic: [Mod] Privat Images  (Read 54290 times)

0 Members and 1 Guest are viewing this topic.

Rembrandt

  • Guest
[Mod] Privat Images
« on: January 07, 2010, 05:19:16 PM »
Mit dieser Modifikation ist es als Admin oder Member möglich, die Befugnisse einzelne Bilder Sichtbar für "Alle", "Registrierte User", "Privat", oder nur "Administratoren" zu setzen.

Big Thank you to *V@no!

Achtung diese Modifikation ist sehr lange. :)

Neu:
je ein neues Datenbankfeld in "Images Table" und "Images Temp Table" dazu speichert euch die datei "install_privat_images.php" aus dem anhang, in euren root und führt sie aus.

Zu Modifzierende Dateien:
1.) admin/images.php
2.) admin/validateimages.php
3.) includes/auth.php
4.) includes/functions.php
5.) includes/session.php
6.) lang/deutsch(englisch)/main.php
7.) root/categories.php
8.) root/details.php
9.) root/global.php
10.) root/index.php
11.) root/member.php
12.) root/search.php
13.) root/top.php
14.) yourtemplates/member_editimage.html
15.) yourtemplates/member_upladform.html


1.) suche in admin/images.php:

if ($action == "") {
  
$action "modifyimages";
}

füge darunter ein:

//#################################### Mod Privat Images ###################################################################
$access_array = array(
  
AUTH_ALL => $lang['all'],
  
AUTH_USER => $lang['userlevel_registered'],
  
AUTH_ACL => $lang['private'],
  
AUTH_ADMIN => $lang['userlevel_admin']
);

function 
show_access_select($title ""$type$status$i) {
  global 
$access_array$HTTP_POST_VARS$i;
  if (isset(
$HTTP_POST_VARS[$type.'_'.$i])) {
   
$status $HTTP_POST_VARS[$type.'_'.$i];
  }
  echo 
"<tr class=\"".get_row_bg()."\" valign=\"top\">\n<td><p class=\"rowtitle\">".$title."</p></td>\n";
  if(isset(
$i)){
  echo 
"<td>\n<select name=\"image_auth_viewimage_".$i."\">\n";
  }
  elseif(!isset(
$i)){
  echo 
"<td>\n<select name=\"image_auth_viewimage\">\n";
  }
  foreach (
$access_array as $key => $val) {
    echo 
"<option value=\"".$key."\"";
    if (
$status == $key) {
      echo 
" selected=\"selected\"";
    }
    echo 
">".$val."</option>\n";
  }
  echo 
"</select>\n</td>\n</tr>\n";
}
//#################################### Mod Privat Images ###################################################################

1.1) suche:

 $image_allow_comments 
intval($HTTP_POST_VARS['image_allow_comments']);

füge darunter ein:

//#################################### Mod Privat Images ###################################################################
  
$image_auth_viewimage $HTTP_POST_VARS['image_auth_viewimage'];
//#################################### Mod Privat Images ###################################################################

1.2) suche:

    $sql 
"UPDATE ".IMAGES_TABLE."
            SET cat_id = 
$cat_id, user_id = $user_id, image_name = '$image_name', image_description = '$image_description', image_keywords = '$image_keywords', image_date = $image_date, image_active = $image_active, image_media_file = '$new_name', image_thumb_file = '$new_thumb_name', image_download_url = '$image_download_url', image_allow_comments = $image_allow_comments, image_downloads = $image_downloads, image_votes = $image_votes, image_rating = '$image_rating', image_hits = $image_hits".$additional_sql."
            WHERE image_id = 
$image_id";

ersetze mit:

//#################################### Mod Privat Images ###################################################################
    
$sql "UPDATE ".IMAGES_TABLE."
            SET cat_id = 
$cat_id, user_id = $user_id, image_name = '$image_name', image_description = '$image_description', image_keywords = '$image_keywords', image_date = $image_date, image_active = $image_active, image_media_file = '$new_name', image_thumb_file = '$new_thumb_name', image_download_url = '$image_download_url', image_allow_comments = $image_allow_comments, image_downloads = $image_downloads, image_votes = $image_votes, image_rating = '$image_rating', image_hits = $image_hits, image_auth_viewimage = $image_auth_viewimage".$additional_sql."
            WHERE image_id = 
$image_id";
//#################################### Mod Privat Images ###################################################################

1.3) suche:

show_cat_select_row
($lang['field_category'], $image_row['cat_id'], 3);

füge darunter ein:

//#################################### Mod Privat Images ###################################################################
  
show_access_select($lang['auth_viewimage'], $key$image_row['image_auth_viewimage'], $i);
//#################################### Mod Privat Images ###################################################################  

1.4) suche:

$user_id 
= (intval($HTTP_POST_VARS['user_id_'.$i]) != 0) ? intval($HTTP_POST_VARS['user_id_'.$i]) : $user_info['user_id'];

füge darüber ein:

//#################################### Mod Privat Images ###################################################################
    
$image_auth_viewimage $HTTP_POST_VARS['image_auth_viewimage_'.$i];
//#################################### Mod Privat Images ###################################################################

1.5) suche:

//Upload Image

füge darüber ein ein:

//#################################### Mod Privat Images ###################################################################
      
$image_auth_viewimage $HTTP_POST_VARS['image_auth_viewimage_'.$i];
//#################################### Mod Privat Images ###################################################################

1.6)suche:

$image_allow_comments 
trim($HTTP_POST_VARS['image_allow_comments_'.$i]);

füge darunter ein:

//#################################### Mod Privat Images ###################################################################
        
$image_auth_viewimage $HTTP_POST_VARS['image_auth_viewimage_'.$i];
//#################################### Mod Privat Images ###################################################################

1.7) suche:

         $sql 
"INSERT INTO ".IMAGES_TABLE."
                (cat_id, user_id, image_name, image_description, image_keywords, image_date, image_active, image_media_file, image_thumb_file, image_download_url, image_allow_comments"
.$additional_field_sql.")
                VALUES
                (
$cat_id$user_id, '$image_name', '$image_description', '$image_keywords', $current_time$image_active, '$new_name', '$new_thumb_name', '$image_download_url', $image_allow_comments".$additional_value_sql.")";

ersetze es mit:

//#################################### Mod Privat Images ###################################################################        
        
$sql "INSERT INTO ".IMAGES_TABLE."
                (cat_id, user_id, image_name, image_description, image_keywords, image_date, image_active, image_media_file, image_thumb_file, image_download_url, image_allow_comments, image_auth_viewimage"
.$additional_field_sql.")
                VALUES
                (
$cat_id$user_id, '$image_name', '$image_description', '$image_keywords', $current_time$image_active, '$new_name', '$new_thumb_name', '$image_download_url', $image_allow_comments$image_auth_viewimage".$additional_value_sql.")";
//#################################### Mod Privat Images ###################################################################       

1.8 ) suche:

show_cat_select_row
($lang['field_category'], 03$i);

füge darunter ein:

//#################################### Mod Privat Images ###################################################################
    
show_access_select($lang['auth_viewimage'], $key$val$i);
//#################################### Mod Privat Images ###################################################################


2.) suche in admin/validateimages.php:

show_admin_header
();

füge darunter ein:

//#################################### Mod Privat Images ###################################################################
$access_array = array(
  
AUTH_ALL => $lang['all'],
  
AUTH_USER => $lang['userlevel_registered'],
  
AUTH_ACL => $lang['private'],
  
AUTH_ADMIN => $lang['userlevel_admin']
);

function 
show_access_select($title ""$type$status$i) {
  global 
$access_array$HTTP_POST_VARS$i;
  if (isset(
$HTTP_POST_VARS[$type.'_'.$i])) {
   
$status $HTTP_POST_VARS[$type.'_'.$i];
  }
  echo 
"<tr class=\"".get_row_bg()."\" valign=\"top\">\n<td><p class=\"rowtitle\">".$title."</p></td>\n";
  if(isset(
$i)){
  echo 
"<td>\n<select name=\"image_auth_viewimage_".$i."\">\n";
  }
  elseif(!isset(
$i)){
  echo 
"<td>\n<select name=\"image_auth_viewimage\">\n";
  }
  foreach (
$access_array as $key => $val) {
    echo 
"<option value=\"".$key."\"";
    if (
$status == $key) {
      echo 
" selected=\"selected\"";
    }
    echo 
">".$val."</option>\n";
  }
  echo 
"</select>\n</td>\n</tr>\n";
}
//#################################### Mod Privat Images ###################################################################

2.1) suche:

$user_id 
= (intval($HTTP_POST_VARS['user_id']) != 0) ? intval($HTTP_POST_VARS['user_id']) : $user_info['user_id'];

füge darunter ein:

//#################################### Mod Privat Images ###################################################################
	

	
$image_auth_viewimage = ($HTTP_POST_VARS['image_auth_viewimage']);
//#################################### Mod Privat Images ###################################################################

2.2) suche:

$sql 
"UPDATE ".IMAGES_TEMP_TABLE."
        SET cat_id = 
$cat_id, user_id = $user_id, image_name = '$image_name', image_description = '$image_description', image_keywords = '$image_keywords', image_date = $image_date, image_media_file = '$new_name', image_thumb_file = '$new_thumb_name', image_download_url = '$image_download_url'".$additional_sql."
        WHERE image_id = 
$image_id";

ersetze es mit:

//#################################### Mod Privat Images ###################################################################
$sql "UPDATE ".IMAGES_TEMP_TABLE."
        SET cat_id = 
$cat_id, user_id = $user_id, image_name = '$image_name', image_description = '$image_description', image_keywords = '$image_keywords', image_date = $image_date, image_media_file = '$new_name', image_thumb_file = '$new_thumb_name', image_download_url = '$image_download_url', image_auth_viewimage = '$image_auth_viewimage'".$additional_sql."
        WHERE image_id = 
$image_id";
//#################################### Mod Privat Images ###################################################################

2.3)suche:

show_user_select_row
($lang['user'], $image_row['user_id']);

füge darunter ein:

//#################################### Mod Privat Images ###################################################################
	
show_access_select($lang['auth_viewimage'], $key$image_row['image_auth_viewimage'], $i);
//#################################### Mod Privat Images ###################################################################  

2.4) suche:

$image_download_url 
addslashes($image_cache[$key]['image_download_url']);

füge darunter ein:

//#################################### Mod Privat Images ###################################################################
      
$image_auth_viewimage $image_cache[$key]['image_auth_viewimage'];
//#################################### Mod Privat Images ###################################################################

2.5)suche:

$sql 
"INSERT INTO ".IMAGES_TABLE."
                  (cat_id, user_id, image_name, image_description, image_keywords, image_date, image_media_file, image_thumb_file, image_download_url"
.$additional_field_sql.")
                  VALUES
                  (
$cat_id$user_id, '$image_name', '$image_description', '$image_keywords', $current_time, '$new_name', '$new_thumb_name', '$image_download_url'".$additional_value_sql.")";

ersetze es mit:

//#################################### Mod Privat Images ###################################################################
$sql "INSERT INTO ".IMAGES_TABLE."
        (cat_id, user_id, image_name, image_description, image_keywords, image_date, image_media_file, image_thumb_file, image_download_url,image_auth_viewimage"
.$additional_field_sql.")
        VALUES
        (
$cat_id$user_id, '$image_name', '$image_description', '$image_keywords', $current_time, '$new_name', '$new_thumb_name', '$image_download_url','$image_auth_viewimage'".$additional_value_sql.")";
//#################################### Mod Privat Images ###################################################################


3.) suche in includes/auth.php:

?>

füge darüber ein:

//#################################### Mod Privat Images ###################################################################
function get_image_permission(){
global 
$site_db$user_info$user_image_access;

if (isset(
$user_image_access) && !empty($user_image_access))
    return 
$user_image_access;

$user_image_access = array();
 
// if ($user_info['user_id'] != 0 && $user_info['user_level'] != GUEST && $user_info['user_level'] != USER_AWAITING) {
    
$current_time time();
    
$sql "SELECT image_id, user_id,image_auth_viewimage
            FROM "
.IMAGES_TABLE."
            WHERE user_id <> "
.$user_info['user_id']." AND image_auth_viewimage <> 0
            "
;
    
$result $site_db->query($sql);
    while (
$row $site_db->fetch_array($result)) {
      
$user_image_access[$row['image_id']] = $row;
     }
   return 
$user_image_access
 }

function 
check_image_permission($type,$image_id) {
global 
$site_db$user_info$user_image_access;
	
/*  if (!isset($image_id[$type])) {
    return false;
    echo "return false";
  }   */
	
if (
$user_image_access[$image_id][$type] == AUTH_ALL || $user_info['user_level'] == ADMIN) {
    return 
true;
    echo 
"return true";
  }
  elseif (
$user_image_access[$image_id][$type] == AUTH_USER && ($user_info['user_level'] != GUEST && $user_info['user_level'] != USER_AWAITING)) {
    return 
true;
    echo 
"return true";
  }
  elseif (
$user_image_access[$image_id][$type] == AUTH_ADMIN && $user_info['user_level'] != ADMIN) {
    return 
false;
    echo 
"return false";
  }
  elseif (
$user_image_access[$image_id][$type] == AUTH_ACL && ($user_info['user_level'] != GUEST && $user_info['user_level'] != USER_AWAITING)) {
    
/* if (isset($user_image_access[$image_id])) {
      for ($i = 0; $i < sizeof($user_image_access[$image_id]); $i++) {
        if (isset($user_image_access[$image_id][$i][$type]) &&  $user_image_access[$image_id][$i][$type] == 1) {
 */          
return false;
          echo 
"return true";
    
//}
   //}
  //}
  
}
  return 
false;
  echo 
"return false";  
	
}
	

	
function 
get_auth_image_sql($type$mode "IN") {
  global 
$auth_image_sql$user_image_access;
  if (!empty(
$auth_image_sql[$type][$mode])) {
    return 
$auth_image_sql[$type][$mode];
  }
  
$auth_image_sql[$type]['IN'] = 0;
  
$auth_image_sql[$type]['NOTIN'] = 0;
  foreach (
$user_image_access as $key => $val) {
    if (!
check_image_permission($type$key)) {
      
$auth_image_sql[$type]['NOTIN'] .= ", ".$key;
    }
    else {
      
$auth_image_sql[$type]['IN'] .= ", ".$key;
    }
  }
  return 
$auth_image_sql[$type][$mode];
}
//#################################### Mod Privat Images ###################################################################


4.) suche in includes/functions.php:

$cat_id_sql 
get_auth_cat_sql("auth_viewcat""NOTIN");

füge darunter ein:

//#################################### Mod Privat Images ###################################################################
$image_id_sql get_auth_image_sql("image_auth_viewimage""NOTIN");
//#################################### Mod Privat Images ###########################################
	


4.1) suche:

$sql 
"SELECT DISTINCT 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, 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.cat_id NOT IN (
$cat_id_sql) AND c.cat_id = i.cat_id
            ORDER BY RAND()"
;

und ersetze es mit:

//#################################### Mod Privat Images ###################################################################
$sql "SELECT DISTINCT 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, 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.cat_id NOT IN (
$cat_id_sql) AND c.cat_id = i.cat_id AND i.image_id NOT IN ($image_id_sql)
            ORDER BY RAND()"
;
//#################################### Mod Privat Images ###################################################################

4.2) suche:

$sql 
"SELECT COUNT(*) as total_images
              FROM "
.IMAGES_TABLE."
              WHERE image_active = 1 AND cat_id NOT IN (
$cat_id_sql)
	
	
	
	
	
	
	
"
;

und ersetze es mit:

//#################################### Mod Privat Images ###################################################################
$sql "SELECT COUNT(*) as total_images
              FROM "
.IMAGES_TABLE."
              WHERE image_active = 1 AND cat_id NOT IN (
$cat_id_sql) AND image_id NOT IN ($image_id_sql)
	
"
;
//#################################### Mod Privat Images ###################################################################

4.3) suche:

$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, 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.cat_id NOT IN (
$cat_id_sql) AND c.cat_id = i.cat_id
            LIMIT 
$number, 1";

und ersetze es:

//#################################### Mod Privat Images ###################################################################
$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, 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.cat_id NOT IN (
$cat_id_sql) AND c.cat_id = i.cat_id AND i.image_id NOT IN ($image_id_sql)
            LIMIT 
$number, 1";
//#################################### Mod Privat Images ###################################################################


5.) suche in includes/session.php:

?>

füge darüber ein:

//#################################### Mod Privat Images ###########################################
	

$user_image_access get_image_permission();
if (
defined("GET_CACHES") && empty($cat_cache)) {

 
$config['cat_order'] = empty($config['cat_order']) ? 'cat_order, cat_name ASC' $config['cat_order'];
  
$sql "SELECT cat_id, cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment
          FROM "
.CATEGORIES_TABLE."
          ORDER BY "
.$config['cat_order']." " .$config['cat_sort'];
  
$result $site_db->query($sql);

  while (
$row $site_db->fetch_array($result)) {
    
$cat_cache[$row['cat_id']] = $row;
    
$cat_parent_cache[$row['cat_parent_id']][] = $row['cat_id'];
  }
  
$site_db->free_result();

  
// --------------------------------------

  
$new_cutoff time() - (60 60 24 $config['new_cutoff']);
 
  
$sql "SELECT cat_id, COUNT(image_id) AS new_images
          FROM "
.IMAGES_TABLE."
          WHERE image_active = 1 AND image_date >= 
$new_cutoff 
          GROUP BY cat_id"
;
  
$result $site_db->query($sql);

  while (
$row $site_db->fetch_array($result)) {
    
$new_image_cache[$row['cat_id']] = $row['new_images'];
  }
  
$site_db->free_result();

  
$sql "SELECT cat_id, COUNT(*) AS num_images
          FROM "
.IMAGES_TABLE."
          WHERE image_active = 1 AND image_id NOT IN ("
.get_auth_image_sql("image_auth_viewimage""NOTIN").")
          GROUP BY cat_id"
;
  
$result $site_db->query($sql);

  while (
$row $site_db->fetch_array($result)) {
    
$cat_cache[$row['cat_id']]['num_images'] = $row['num_images'];
  }
  
$site_db->free_result();
//end if GET_CACHES 
//#################################### Mod Privat Images ###########################################


6.) suche in lang/deutsch(englisch)/main.php:

$lang
['userlevel_guest'] = "Gast";

füge darunter ein:

//#################################### Privat Images ###################################################################
$lang['userlevel_all'] = "Alle";
$lang['userlevel_registered'] = "Registrierte User";
$lang['userlevel_private']= "Privat";
$lang['userlevel_admins'] = "Administratoren";
$lang['auth_viewimage'] = "Bilddetails sehen:";
//#################################### Privat Images ###################################################################

Optional english/main.php

//#################################### Privat Images ###################################################################
$lang['userlevel_all'] = "All";
$lang['userlevel_registered'] = "Registered User";
$lang['userlevel_private']= "Privat";
$lang['userlevel_admins'] = "Administratoren";
$lang['auth_viewimage'] = "Show Image detail:";
//#################################### Privat Images ###################################################################


7.) suche in  root/categories.php:

$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.cat_id = 
$cat_id AND c.cat_id = i.cat_id 
        ORDER BY "
.$config['image_order']." ".$config['image_sort'].", i.image_id ".$config['image_sort']."
        LIMIT 
$offset$perpage ";

ersetze es mit:

//#################################### Privat Images ###################################################################
$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, i.image_auth_viewimage".$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.cat_id = 
$cat_id AND c.cat_id = i.cat_id  AND i.image_id NOT IN (".get_auth_image_sql("image_auth_viewimage""NOTIN").")
        ORDER BY "
.$config['image_order']." ".$config['image_sort'].", i.image_id ".$config['image_sort']."
        LIMIT 
$offset$perpage ";
//#################################### Privat Images ###################################################################


8.) suche in root/details.php:

$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").get_user_table_field(", u.""user_email")."
        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_id = 
$image_id AND i.image_active = 1 AND c.cat_id = i.cat_id";


ersetze es mit:

//#################################### Mod Privat Images ################################################################### 
$check_image_auth_viewimage = (check_image_permission("image_auth_viewimage"$image_id)) ? " " "AND NOT i.image_id = '$image_id'";

$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, i.image_auth_viewimage".$additional_sql.", c.cat_name".get_user_table_field(", u.""user_name").get_user_table_field(", u.""user_email")."
        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_id = 
$image_id AND i.image_active = 1 AND c.cat_id = i.cat_id $check_image_auth_viewimage";
//#################################### Mod Privat Images ################################################################### 


9.) suche in  root/global.php:

if (defined("GET_CACHES")) {

und ersetze es mit:

//#################################### Mod Privat Images ###################################################################
 //if (defined("GET_CACHES")) { 
if (defined("GET_CACHES") && (defined("IN_CP") || isset($global_get_caches))) {
//#################################### Mod Privat Images ###################################################################


10.) suche in  root/index.php:

$num_new_images 
$config['image_cells'];
$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 c.cat_id = i.cat_id AND i.cat_id NOT IN ("
.get_auth_cat_sql("auth_viewcat""NOTIN").")
        ORDER BY i.image_date DESC
        LIMIT 
$num_new_images";

ersetze es mit:

//#################################### Mod Privat Images ################################################################### 
$num_new_images $config['image_cells'];
$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, i.image_auth_viewimage".$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 c.cat_id = i.cat_id AND i.cat_id NOT IN ("
.get_auth_cat_sql("auth_viewcat""NOTIN").") AND i.image_id NOT IN (".get_auth_image_sql("image_auth_viewimage""NOTIN").")
        ORDER BY i.image_date DESC
        LIMIT 
$num_new_images";
//#################################### Mod Privat Images ################################################################### 


11.)suche in root/member.php:
suche im abschnitt: if ($action == "updateimage")

$image_keywords 
ereg_replace("( ){2,}"" "$image_keywords);

füge darunter ein:

//####################################  Mod Privat Image ###################################################################
$image_auth_viewimage $HTTP_POST_VARS['image_auth_viewimage'];
//#################################### Mod Privat Images ###################################################################

11.1) suche im abschnitt: if ($action == "updateimage")

$sql 
"UPDATE ".IMAGES_TABLE."
            SET image_name = '
$image_name', image_description = '$image_description', image_keywords = '$image_keywords'".$additional_sql."
            WHERE image_id = 
$image_id";

ersetze es mit:

//####################################  Mod Privat Image ###################################################################
$sql "UPDATE ".IMAGES_TABLE."
            SET image_name = '
$image_name', image_description = '$image_description', image_keywords = '$image_keywords', image_auth_viewimage = $image_auth_viewimage".$additional_sql."
            WHERE image_id = 
$image_id";
//####################################  Mod Privat Image ###################################################################

11.2) suche im abschnitt if ($action == "editimage")

  $sql 
"SELECT image_id, cat_id, user_id, image_name, image_description, image_keywords, image_allow_comments".$additional_sql."
          FROM "
.IMAGES_TABLE."
          WHERE image_id = 
$image_id";

ersetze es mit:

//#################################### Mod Privat Images ###################################################################
  
$sql "SELECT image_id, cat_id, user_id, image_name, image_description, image_keywords, image_allow_comments, image_auth_viewimage".$additional_sql."
          FROM "
.IMAGES_TABLE."
          WHERE image_id = 
$image_id";
//#################################### Mod Privat Images ###################################################################  

11.3) suche im abschnitt if ($action == "editimage")

$image_allow_comments 
= (isset($HTTP_POST_VARS['image_allow_comments'])) ? intval($HTTP_POST_VARS['image_allow_comments']) : $image_row['image_allow_comments'];

füge darunter ein:

//#################################### Mod Privat Images ###################################################################
$access_array = array(
  
AUTH_ALL => $lang['userlevel_all'],
  
AUTH_USER => $lang['userlevel_registered'],
  
AUTH_ACL => $lang['userlevel_private'],
  
AUTH_ADMIN => $lang['userlevel_admins']
);

  
$status = (isset($HTTP_POST_VARS['image_auth_viewimage']))? $HTTP_POST_VARS['image_auth_viewimage'] : $image_row['image_auth_viewimage'];
  
$access_select =  "<td class=\"row1\">\n<select class=\"input\" name=\"image_auth_viewimage\">\n";
  foreach (
$access_array as $key => $val) {
    
$access_select .=  "<option value=\"".$key."\"";
      if (
$status == $key) {
        
$access_select .= " selected=\"selected\"";
      }
    
$access_select .=  ">".$val."</option>\n";
  }
    
$access_select .=  "</select>\n</td>\n</tr>\n";
//#################################### Mod Privat Images ###################################################################

11.4) suche im abschnitt if ($action == "editimage")

$site_template
->register_vars(array(

füge darunter ein:

//#################################### Mod Privat Images ###################################################################
"access_select" => $access_select,
"auth_viewimage" => $lang['auth_viewimage'],
//#################################### Mod Privat Images ###################################################################

11.5) suche im abschnitt if ($action == "uploadimage")

$image_keywords 
ereg_replace("( ){2,}"" "$image_keywords);

füge darunter ein:

//#################################### Mod Privat Images ###################################################################
  
$image_auth_viewimage $HTTP_POST_VARS['image_auth_viewimage'];
//#################################### Mod Privat Images ###################################################################

11.6) suche im abschnitt if ($action == "uploadimage")

$sql 
"INSERT INTO ".IMAGES_TABLE."
                (cat_id, user_id, image_name, image_description, image_keywords, image_date, image_active, image_media_file, image_thumb_file, image_download_url, image_allow_comments"
.$additional_field_sql.")
                VALUES
                (
$cat_id, ".$user_info['user_id'].", '$image_name', '$image_description', '$image_keywords', $current_time$image_active, '$new_name', '$new_thumb_name', '$image_download_url', $image_allow_comments".$additional_value_sql.")";

ersetze es mit:

//#################################### Mod Privat Images ###################################################################
$sql "INSERT INTO ".IMAGES_TABLE."
                (cat_id, user_id, image_name, image_description, image_keywords, image_date, image_active, image_media_file, image_thumb_file, image_download_url, image_allow_comments, image_auth_viewimage"
.$additional_field_sql.")
                VALUES
                (
$cat_id, ".$user_info['user_id'].", '$image_name', '$image_description', '$image_keywords', $current_time$image_active, '$new_name', '$new_thumb_name', '$image_download_url', $image_allow_comments,$image_auth_viewimage".$additional_value_sql.")";
//#################################### Mod Privat Images ###################################################################

11.7) suche im abschnitt if ($action == "uploadimage")

$sql 
"INSERT INTO ".IMAGES_TEMP_TABLE."
                (cat_id, user_id, image_name, image_description, image_keywords, image_date, image_media_file, image_thumb_file, image_download_url"
.$additional_field_sql.")
                VALUES
                (
$cat_id, ".$user_info['user_id'].", '$image_name', '$image_description', '$image_keywords', $current_time, '$new_name', '$new_thumb_name', '$image_download_url'".$additional_value_sql.")";

ersetze es mit:

//#################################### Mod Privat Images ###################################################################
$sql "INSERT INTO ".IMAGES_TEMP_TABLE."
                (cat_id, user_id, image_name, image_description, image_keywords, image_date, image_media_file, image_thumb_file, image_download_url,image_auth_viewimage"
.$additional_field_sql.")
                VALUES
                (
$cat_id, ".$user_info['user_id'].", '$image_name', '$image_description', '$image_keywords', $current_time, '$new_name', '$new_thumb_name', '$image_download_url','$image_auth_viewimage'".$additional_value_sql.")";
//#################################### Mod Privat Images ###################################################################

11.8 ) suche im abschnitt if ($action == "uploadform")

$site_template
->register_vars(array(

füge darüber ein:

//#################################### Mod Privat Images ###################################################################
$access_array = array(
  
AUTH_ALL => $lang['userlevel_all'],
  
AUTH_USER => $lang['userlevel_registered'],
  
AUTH_ACL => $lang['userlevel_private'],
  
AUTH_ADMIN => $lang['userlevel_admins']
);
  
$status = (isset($HTTP_POST_VARS['image_auth_viewimage']))? $HTTP_POST_VARS['image_auth_viewimage'] : $image_row['image_auth_viewimage'];
  
$access_select =  "<td class=\"row1\">\n<select class=\"input\" name=\"image_auth_viewimage\">\n";
  foreach (
$access_array as $key => $val) {
    
$access_select .=  "<option value=\"".$key."\"";
      if (
$status == $key) {
        
$access_select .= " selected=\"selected\"";
      }
    
$access_select .=  ">".$val."</option>\n";
  }
    
$access_select .=  "</select>\n</td>\n</tr>\n";
//#################################### Mod Privat Images ###################################################################

11.9.) suche im abschnitt if ($action == "uploadform")

$site_template
->register_vars(array(

füge darunter ein:

//#################################### Mod Privat Images ###################################################################
  
"access_select" => $access_select,
  
"auth_viewimage" => $lang['auth_viewimage'],
//#################################### Mod Privat Images ###################################################################


12.) suche in root/search.php:

if (!empty($sql_where_query)) {
    
$sql "SELECT COUNT(*) AS num_rows_all
            FROM "
.IMAGES_TABLE." i
            WHERE i.image_active = 1 
$sql_where_query
            
$cat_id_sql
	
"
;

ersetze es mit:

//#################################### Mod Privat Images ###################################################################
 
if (!empty($sql_where_query)) {
    
$sql "SELECT COUNT(*) AS num_rows_all
            FROM "
.IMAGES_TABLE." i
            WHERE i.image_active = 1 
$sql_where_query
            
$cat_id_sql AND i.image_id NOT IN (".get_auth_image_sql("image_auth_viewimage""NOTIN").")
	
"
;
//#################################### Mod Privat Images ###################################################################

12.1) suche:

  $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
          
$sql_where_query
          AND c.cat_id = i.cat_id 
$cat_id_sql
          ORDER BY "
.$config['image_order']." ".$config['image_sort'].", image_id ".$config['image_sort']."
          LIMIT 
$offset$perpage";

ersetze es mit:

//#################################### Mod Privat Images ###################################################################
  
$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 NOT IN ("
.get_auth_image_sql("image_auth_viewimage""NOTIN").")
          
$sql_where_query
          AND c.cat_id = i.cat_id 
$cat_id_sql
          ORDER BY "
.$config['image_order']." ".$config['image_sort'].", image_id ".$config['image_sort']."
          LIMIT 
$offset$perpage";
//#################################### Mod Privat Images ###################################################################


13.) suche in root/top.php:

$cat_id_sql 
get_auth_cat_sql("auth_viewcat""NOTIN");

füge darunter ein:

//#################################### Mod Privat Images ###################################################################
	
$image_id_sql get_auth_image_sql("image_auth_viewimage""NOTIN");
//#################################### Mod Privat Images ###################################################################

13.1) suche  4x :

 WHERE i
.image_active AND i.cat_id NOT IN ($cat_id_sql) AND i.cat_id c.cat_id
        $cat_match_sql

ersetze es mit:

 WHERE i
.image_active AND i.cat_id NOT IN ($cat_id_sql) AND i.cat_id c.cat_id
        $cat_match_sql 
AND i.image_id NOT IN ($image_id_sql)


14.)suche in yourtemplates/member_editimage.html:
Code: [Select]
   <textarea name="image_keywords" cols="30" rows="10" wrap="virtual" class="textarea">{image_keywords}</textarea>
  </td>      
</tr>
füge darunter ein:
Code: [Select]
<tr>
  <td class="row1" valign="top"><b>{auth_viewimage}</b></td>
  {access_select}
</tr>

15.) suche in yourtemplates/member_upladform.html:
Code: [Select]
 <textarea cols="30" class="textarea" rows="10" name="image_keywords">{image_keywords}</textarea>
 </td>
</tr>
füge darunter ein:
Code: [Select]
<tr>
  <td class="row1" valign="top"><b>{auth_viewimage}</b></td>
  {access_select}
</tr>

das war es :)

mfg Andi
« Last Edit: November 22, 2010, 04:47:51 AM by Rembrandt »

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [Mod] Privat Images
« Reply #1 on: January 08, 2010, 01:59:59 AM »
Thank you for sharing this mod.

The random image I think can be fixed by replacing your step 4.3 (by the way you missed step 4.2 in the instructions) with:
find
      $sql "SELECT COUNT(*) as total_images
              FROM "
.IMAGES_TABLE."
              WHERE image_active = 1 AND cat_id NOT IN (
$cat_id_sql)";


replace with this:
      $sql "SELECT COUNT(*) as total_images
              FROM "
.IMAGES_TABLE."
              WHERE image_active = 1 AND cat_id NOT IN (
$cat_id_sql$image_id_sql";


As of number of images in categories bug - possible solution is to replace in global.php:
if (defined("GET_CACHES") && defined) {

with:
if (defined("GET_CACHES") && (defined("IN_CP") || isset($global_get_caches))) {


Then copy entire section that starts with the line you just replaced (basically the entire code block that creates $cat_cache) to the end of sessions.php and replace first line with:
if (defined("GET_CACHES") && empty($cat_cache)) {


After that do your magic with the auth on the copied code in sessions.php
« Last Edit: January 08, 2010, 02:21:10 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)

Rembrandt

  • Guest
Re: [Mod] Privat Images
« Reply #2 on: January 08, 2010, 08:48:14 AM »
Hi!

Thank you for your answer, @V@no.

It works !  :D :D

mfg Andi

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [Mod] Privat Images
« Reply #3 on: January 08, 2010, 03:01:21 PM »
I'm glad it worked :)

A little optimization can be done:
in step 3
above
$user_image_access = array();

insert
  if (isset($user_image_access) && !empty($user_image_access))
    return 
$user_image_access;


In steps 4,7,8,10,12 you don't need anymore
$user_access get_image_permission();
it is now included in step 5.
and I'd suggest rewrite steps 4.x a little, because they all are using the same list of "auth" images, store that list into $image_id_sql, but without any extra mysql commands:
$image_id_sql get_auth_image_sql("image_auth_viewimage""NOTIN");
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)

Rembrandt

  • Guest
Re: [Mod] Privat Images
« Reply #4 on: January 08, 2010, 05:18:59 PM »
done, I've made the changes in the post, thx again !!  :D
 I'm so glad it works the mod.  :D

Offline Bommel

  • Full Member
  • ***
  • Posts: 114
    • View Profile
Re: [Mod] Privat Images
« Reply #5 on: January 10, 2010, 12:21:24 PM »
Hallo allerseits,

zuerst einmal ein Dankeschön für diesen MOD.  :thumbup:

Mir ist aufgefallen dass im Schritt 1.2 der Code, den es zu finden gilt, bereits als "Private MOD" deklariert ist. War etwas irritierend.  :?

Weiterhin trat bei dem Ausführen der install_privat_images.php bei mir ein Fehler auf (siehe Screenshot). Auf dem ersten Blick scheint die MOD korrekt zu funktionieren. Was mir aber jedoch auffällt - man kann als Administrator keine Bilder nachträglich mit entsprechenden Rechten versehen, da man direkt in den Adminbereich geleitet wird! Oder ist da etwa ein Fehler bei mir vorhanden bzw. habe ich etwas übersehen?

Freundliche Grüße, Bommel
Freundliche Grüße, Bommel

Nicht die Geduld mit mir verlieren, ich bin noch am Lernen./ Do not lose the patience with me, I am still in the learning. ;)

Rembrandt

  • Guest
Re: [Mod] Privat Images
« Reply #6 on: January 10, 2010, 12:50:06 PM »
Hi!

@Bommel

bei punkt 1.2 hatte ich es vergessen rauszunehmen.

die install_privat_images.php hättest du im root der galerie ausführen sollen bevor du den code einbaust, was aber letztendlich vollkommend egal ist.

das du als admin direkt in das ACP kommst ist, normal und hat nichts mit dem mod zu tun, wenn du die bildrechte dort nicht ändern kannst b.z.w das feld überhaupt nicht siehst, schau dir punkt 1.3) nochmal an.

mfg Andi

Offline Bommel

  • Full Member
  • ***
  • Posts: 114
    • View Profile
Re: [Mod] Privat Images
« Reply #7 on: January 10, 2010, 01:02:54 PM »
Hallo Rembrandt,

danke für die schnelle Antwort. :) Unter Punkt 1.3 kann ich bei mir keinen Fehler erkennen.  :?:

Was aber soeben auch noch aufgetreten ist, wenn ich auf die Top10 gehen will:

Quote
Parse error: syntax error, unexpected T_STRING in /home/WH4448059/wwwroot/top.php on line 53

Es handelt sich dabei um Punkt 13.1, wo 5x ein und derselbe Code ersetzt werden musste. Hast du eine Idee, was da vor sich geht?

Freundliche Grüße, Bommel
Freundliche Grüße, Bommel

Nicht die Geduld mit mir verlieren, ich bin noch am Lernen./ Do not lose the patience with me, I am still in the learning. ;)

Rembrandt

  • Guest
Re: [Mod] Privat Images
« Reply #8 on: January 10, 2010, 01:06:44 PM »
ja sorry es gibt nur 4 davon.

Offline Bommel

  • Full Member
  • ***
  • Posts: 114
    • View Profile
Re: [Mod] Privat Images
« Reply #9 on: January 10, 2010, 01:16:08 PM »
Hallo Rembrandt,

nein, es gibt tatsächlich 5 Zeilen wo dieser Code auftaucht. Habe jetzt den ersten in Zeile 53  zurück geändert und es kommt jetzt dieser Fehler:

Quote
Fatal error: Can't use function return value in write context in /home/WH4448059/wwwroot/top.php on line 53

Das Problem mit den Rechte setzen als Administrator hat sich mittlerweile erledigt.

Gruß Bommel
Freundliche Grüße, Bommel

Nicht die Geduld mit mir verlieren, ich bin noch am Lernen./ Do not lose the patience with me, I am still in the learning. ;)

Rembrandt

  • Guest
Re: [Mod] Privat Images
« Reply #10 on: January 10, 2010, 01:20:16 PM »
ok alles klar die zeile 53 darfst du natürlich nicht ändern, das ist die originale:
Code: [Select]
$cat_match_sql = ($cat_id && check_permission("auth_viewcat", $cat_id)) ? "AND i.cat_id = '$cat_id' " : "";
es gibt in der top.php 4 SQL querys und dort drinnen befindet sich
Code: [Select]
cat_match_sql und die ersetzt du mit
Code: [Select]
$cat_match_sql AND i.image_id NOT IN ($image_id_sql)

Offline Bommel

  • Full Member
  • ***
  • Posts: 114
    • View Profile
Re: [Mod] Privat Images
« Reply #11 on: January 10, 2010, 01:26:00 PM »
Hallo Rembrandt,

besten Dank.  8) Jetzt funktioniert die Top10 wieder. Mir grauste es schon vor dem kompletten rückgängig machen.  :wink:

Nochmals :thumbup: zu diesem MOD.

Freundliche Grüße, Bommel
Freundliche Grüße, Bommel

Nicht die Geduld mit mir verlieren, ich bin noch am Lernen./ Do not lose the patience with me, I am still in the learning. ;)

Rembrandt

  • Guest
Re: [Mod] Privat Images
« Reply #12 on: January 10, 2010, 01:27:01 PM »
warum willst du es den wieder rückgängig machen?

Offline Bommel

  • Full Member
  • ***
  • Posts: 114
    • View Profile
Re: [Mod] Privat Images
« Reply #13 on: January 10, 2010, 01:31:17 PM »
Hallo Rembrandt,

von wollen war keine Rede, mehr von müssen, wenn der Fehler nicht so schnell gefunden wäre. ;)


Freundliche Grüße, Bommel
Freundliche Grüße, Bommel

Nicht die Geduld mit mir verlieren, ich bin noch am Lernen./ Do not lose the patience with me, I am still in the learning. ;)

Rembrandt

  • Guest
Re: [Mod] Privat Images
« Reply #14 on: January 10, 2010, 01:34:38 PM »
ahh... grauste  :D