Announcement

  •  » Engine
  •  » Feature: Configurable privacy level of newly uploaded images

#1 2011-04-29 15:27:51

stim
Member
Netherlands
2011-04-24
10

Feature: Configurable privacy level of newly uploaded images

Currently the privacy level of new images is 0 (hard coded).
I'd like to use my piwigo install for a closed community, where the new images (that any user can upload) should not be accessible to the public by default. Therefore I suggest that the privacy level of newly uploaded images should be configurable.

Using the following changes this can be implemented:
- add the next line to default_conf.inc.php

Code:

$conf['image_default_privacy_level'] = 0;

-apply the following diff (note: not only the core files are touched, since one change concerns the community plugin):

Code:

diff --git a/piwigo/admin/batch_manager_global.php b/piwigo/admin/batch_manager_global.php
--- a/piwigo/admin/batch_manager_global.php
+++ b/piwigo/admin/batch_manager_global.php
@@ -482,7 +482,7 @@
       'filter_level_options'=> get_privacy_level_options(),
       'filter_level_options_selected' => isset($_SESSION['bulk_manager_filter']['level'])
         ? $_SESSION['bulk_manager_filter']['level']
-        : 0,
+        : $conf['image_default_privacy_level'],
     )
   );
 
@@ -590,7 +590,7 @@
 $template->assign(
     array(
       'level_options'=> get_privacy_level_options(),
-      'level_options_selected' => 0,
+      'level_options_selected' => $conf['image_default_privacy_level'],
     )
   );
 
diff --git a/piwigo/admin/include/photos_add_direct_prepare.inc.php b/piwigo/admin/include/photos_add_direct_prepare.inc.php
--- a/piwigo/admin/include/photos_add_direct_prepare.inc.php
+++ b/piwigo/admin/include/photos_add_direct_prepare.inc.php
@@ -144,7 +144,7 @@
 
 
 // image level options
-$selected_level = isset($_POST['level']) ? $_POST['level'] : 0;
+$selected_level = isset($_POST['level']) ? $_POST['level'] : $conf['image_default_privacy_level'];
 $template->assign(
     array(
       'level_options'=> get_privacy_level_options(),
diff --git a/piwigo/admin/site_update.php b/piwigo/admin/site_update.php
--- a/piwigo/admin/site_update.php
+++ b/piwigo/admin/site_update.php
@@ -805,7 +805,7 @@
       'display_info' => false,
       'add_to_caddie' => false,
       'subcats_included' => true,
-      'privacy_level_selected' => 0,
+      'privacy_level_selected' => $conf['image_default_privacy_level'],
       'meta_all'  => false,
       'meta_empty_overrides'  => false,
     );
diff --git a/piwigo/plugins/community/add_photos.php b/piwigo/plugins/community/add_photos.php
--- a/piwigo/plugins/community/add_photos.php
+++ b/piwigo/plugins/community/add_photos.php
@@ -184,6 +184,5 @@
   }
   else
   {
-    // the level of a user upload photo with no moderation is 0
     $query = '
 UPDATE '.IMAGES_TABLE.'
@@ -188,6 +187,6 @@
     $query = '
 UPDATE '.IMAGES_TABLE.'
-  SET level = 0
+  SET level = '.$conf['image_default_privacy_level'].'
   WHERE id IN ('.implode(',', $image_ids).')
 ;';
     pwg_query($query);

I hope to welcome this change in upcoming releases.

-Tim

Offline

 

#2 2011-04-30 17:32:26

LucMorizur
Member
Vienne (Isère) - France
2009-04-30
171

Re: Feature: Configurable privacy level of newly uploaded images

Hi;

don't know if this can suit you -- probably you already know about that, anyway -- but already in local/config/config.inc.php the configuration variable $conf['newcat_default_status'] allows you to automatically set a new category (album) to private status.

Yet I don't beleive it's possible to assign a group authorization to a new album automatically, without a Personal Plugin. But thanks to a Personal Plugin I would be surprised if it makes big difficulties.


Our gallery : Le Site à Nous (a silly name in french, but here I don't care ;-) ! )
An event, a new gallery ? Plugin Event Cats
My test gallery : Tests Piwigo de Luc
Thanksalot for this beautiful project.

Offline

 

#3 2011-05-01 10:39:28

stim
Member
Netherlands
2011-04-24
10

Re: Feature: Configurable privacy level of newly uploaded images

The effect of that setting would be quite different though.
With my change, the default setting in the upload form is changed (exept in the community plugin, where the privacy field is not shown in the form), but admins can change this value as they see fit.

Non-admins uploading via the community plugin have no choice about what privacy setting their uploads will get. But with my change the gallery owner has a choice to define this in advance.

I want the registered members to be able to upload images, and have them visible for other registered members. However, I don't want this images visible for the world, until verified by an administrator.

Thinking about it, the only important change (from my point of view) is the change to the community plugin (but changing the default setting in the admin forms is a nice benefit). I guess changing it to a preference in the community plugin instead of piwigo configuration would work too.
However, currently the code contains the literal '0' here and there, where I replaced it with the configuration value. This by itself seems like an improvement, since the current code is violating the no-magic-number guideline.

Offline

 

#4 2011-05-01 22:45:18

LucMorizur
Member
Vienne (Isère) - France
2009-04-30
171

Re: Feature: Configurable privacy level of newly uploaded images

OK; well let's see if plg (who built [extension by plg] Community) is interested by your proposal. Notify him if he doesn't answer soon.


Our gallery : Le Site à Nous (a silly name in french, but here I don't care ;-) ! )
An event, a new gallery ? Plugin Event Cats
My test gallery : Tests Piwigo de Luc
Thanksalot for this beautiful project.

Offline

 

#5 2011-05-02 15:39:18

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13790

Re: Feature: Configurable privacy level of newly uploaded images

Hi stim,

Your request looks a lot like [Bugtracker] ticket 1073 and as you can see I created it myself, I agree with you.

Concerning the Community plugin, let's be clear about the current (version 2.2.i) way it works:

if the upload is "moderated", the privacy level is 16, which is a trick to have it invisible on the gallery (even for admins).

if the upload is not moderated, the privacy level is 0.

Before that, I had coded something more complex, but it was too complex to understand.

If we had a default_privacy_level, it must be less or equal to the privacy level of the upload users, or else it would not be visible to him, and that's not good in my opinion.

Let's imagine you user Craig (level 2, Friends) uploads a new photo a you have defined the default privacy level to 4. Then what should be better? decreasing the level to 2 so that Craig can see his own upload? or keeping 4 and Craig won't see his own photo?

Offline

 

#6 2011-05-02 16:38:17

stim
Member
Netherlands
2011-04-24
10

Re: Feature: Configurable privacy level of newly uploaded images

Hi Plg,

Concerning the community plugin, I agree with your description of how it currently works.
With my change, if moderation is turned off, the privacy levels of the images are set to $conf['images_default_privacy_level'] instead of 0.

Your example with Craig stays quite straightforward. Currently, when the uploads are moderated, he won't be able to see the images either. So with the new 'default_privacy_level', if he has a too low a level, he has lost nothing. However, all family can see the new images straight away.

I agree with this scheme, because in my use case I want to prevent 'leaking' sensitive images, but share new uploads with the community as soon as possible. :)

--

About [Bugtracker] ticket 1073, I don't see the trouble with the MySql default value. When an image is uploaded by the administrator (through whatever form) it is always accompanied by a $_POST["level"] value, isn't it?
If I'm correct here, then the database' default level is already always overwritten on inserts.

My changes also only allow the forms default to be configurable.
(Btw, I have implemented the changes I proposed, and noticed that clicking the front-page button to the synchronization page is a submit, effectively overwriting any default form values).

-Tim

Offline

 

#7 2011-05-02 20:03:29

stim
Member
Netherlands
2011-04-24
10

Re: Feature: Configurable privacy level of newly uploaded images

Hi,

While looking over the community plugin interface again, I was thinking the following:
You could just add a privacy level setting to the individual permission configurations. In addition to the current trust setting you allow the admin to define the privacy level of the uploaded images by that group.

Maybe the privacy level can not be set when trust is low, or the uploads receive that privacy level anyway. The 'moderate' setting then becomes an indication that the admins will receive notifications.

Offline

 

#8 2016-08-25 00:15:42

jesiegel
Guest

Re: Feature: Configurable privacy level of newly uploaded images

How do you implement this? i want to do the same, closed community except for registered users.  id love to implement this feature if possible.

stim wrote:

Currently the privacy level of new images is 0 (hard coded).
I'd like to use my piwigo install for a closed community, where the new images (that any user can upload) should not be accessible to the public by default. Therefore I suggest that the privacy level of newly uploaded images should be configurable.

Using the following changes this can be implemented:
- add the next line to default_conf.inc.php

Code:

$conf['image_default_privacy_level'] = 0;

-apply the following diff (note: not only the core files are touched, since one change concerns the community plugin):

Code:

diff --git a/piwigo/admin/batch_manager_global.php b/piwigo/admin/batch_manager_global.php
--- a/piwigo/admin/batch_manager_global.php
+++ b/piwigo/admin/batch_manager_global.php
@@ -482,7 +482,7 @@
       'filter_level_options'=> get_privacy_level_options(),
       'filter_level_options_selected' => isset($_SESSION['bulk_manager_filter']['level'])
         ? $_SESSION['bulk_manager_filter']['level']
-        : 0,
+        : $conf['image_default_privacy_level'],
     )
   );
 
@@ -590,7 +590,7 @@
 $template->assign(
     array(
       'level_options'=> get_privacy_level_options(),
-      'level_options_selected' => 0,
+      'level_options_selected' => $conf['image_default_privacy_level'],
     )
   );
 
diff --git a/piwigo/admin/include/photos_add_direct_prepare.inc.php b/piwigo/admin/include/photos_add_direct_prepare.inc.php
--- a/piwigo/admin/include/photos_add_direct_prepare.inc.php
+++ b/piwigo/admin/include/photos_add_direct_prepare.inc.php
@@ -144,7 +144,7 @@
 
 
 // image level options
-$selected_level = isset($_POST['level']) ? $_POST['level'] : 0;
+$selected_level = isset($_POST['level']) ? $_POST['level'] : $conf['image_default_privacy_level'];
 $template->assign(
     array(
       'level_options'=> get_privacy_level_options(),
diff --git a/piwigo/admin/site_update.php b/piwigo/admin/site_update.php
--- a/piwigo/admin/site_update.php
+++ b/piwigo/admin/site_update.php
@@ -805,7 +805,7 @@
       'display_info' => false,
       'add_to_caddie' => false,
       'subcats_included' => true,
-      'privacy_level_selected' => 0,
+      'privacy_level_selected' => $conf['image_default_privacy_level'],
       'meta_all'  => false,
       'meta_empty_overrides'  => false,
     );
diff --git a/piwigo/plugins/community/add_photos.php b/piwigo/plugins/community/add_photos.php
--- a/piwigo/plugins/community/add_photos.php
+++ b/piwigo/plugins/community/add_photos.php
@@ -184,6 +184,5 @@
   }
   else
   {
-    // the level of a user upload photo with no moderation is 0
     $query = '
 UPDATE '.IMAGES_TABLE.'
@@ -188,6 +187,6 @@
     $query = '
 UPDATE '.IMAGES_TABLE.'
-  SET level = 0
+  SET level = '.$conf['image_default_privacy_level'].'
   WHERE id IN ('.implode(',', $image_ids).')
 ;';
     pwg_query($query);

I hope to welcome this change in upcoming releases.

-Tim

 
  •  » Engine
  •  » Feature: Configurable privacy level of newly uploaded images

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact