WP Photo Album Plus - Version 8.2.04.007

Version Description

= 8.1.08 =

  • This version addresses various bug fixes, feature requests and security fixes.
Download this release

Release Info

Developer opajaap
Plugin Icon wp plugin WP Photo Album Plus
Version 8.2.04.007
Comparing to
See all releases

Code changes from version 8.2.04.006 to 8.2.04.007

changelog.txt CHANGED
@@ -7,7 +7,8 @@ WP Photo Album Plus Changelog
7
  * To improve previews, you can now add your theme and custom css at the backend. See new settings Advanced settings -> Admin -> VI -> Items 15, 16 and 17.
8
  * Improved algorithm to decide if an album or item (photo, video, document) is visble for the current visitor.
9
  This takes in account: itmem (photo) status, album status, user status: admin/superuser, logged-in or out, owner of the item or not etc.
10
- Note: Published items that reside in albums that can not be seen by the current visitor are also hidden.
 
11
 
12
  = 8.2.03 =
13
 
7
  * To improve previews, you can now add your theme and custom css at the backend. See new settings Advanced settings -> Admin -> VI -> Items 15, 16 and 17.
8
  * Improved algorithm to decide if an album or item (photo, video, document) is visble for the current visitor.
9
  This takes in account: itmem (photo) status, album status, user status: admin/superuser, logged-in or out, owner of the item or not etc.
10
+ Note: The visibility of items that reside in albums that can not be seen by the current visitor,
11
+ depends upon their own status when they are explicitly requested e.g. by a shortcode like [wppa type="photo" photo=".."].
12
 
13
  = 8.2.03 =
14
 
wppa-album-admin-autosave.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * create, edit and delete albums
6
- * Version 8.2.04.006
7
  *
8
  */
9
 
@@ -2681,7 +2681,7 @@ global $wpdb;
2681
  <td>' . $id . ( $show_nl ? '(' . wppa_get_nesting_level( $id ) . ')' : '' ) . '</td>
2682
  <td>' . esc_html( stripslashes( $album['name'] ) ) . '</td>
2683
  <td><small>' . esc_html( stripslashes( $album['description'] ) ) . '</small></td>' .
2684
- ( current_user_can( 'administrator' ) ? '<td>' . $album['owner'] . '</td>' : '' ) . '
2685
  <td>' . $album['a_order'] . '</td>
2686
  <td>' . wppa_get_album_name( $album['a_parent'], array( 'extended' => true ) ) . '</td>
2687
  <td>' . $na . '/' . $np . '/' . $nm . '/' . $ns . '</td>
@@ -3333,9 +3333,9 @@ global $wpdb;
3333
  $result .= '
3334
  <td>' . esc_html( stripslashes( $album['name'] ) ) . '</td>
3335
  <td><small>' . esc_html( stripslashes( $album['description'] ) ) . '</small></td>' .
3336
- ( current_user_can( 'administrator' ) ? '<td>' . $album['owner'] . '</td>' : '' ) . '
3337
  <td>' . $album['a_order'] . '</td>
3338
- <td>' . esc_html( stripslashes( wppa_get_album_name( $album['a_parent'] ) ) ) . '</td>
3339
  <td>' . $na . '/' . $np . '/' . $nm . '/' . $ns . '</td>';
3340
 
3341
  if ( wppa_have_access( $album['id'] ) ) {
3
  * Package: wp-photo-album-plus
4
  *
5
  * create, edit and delete albums
6
+ * Version 8.2.04.007
7
  *
8
  */
9
 
2681
  <td>' . $id . ( $show_nl ? '(' . wppa_get_nesting_level( $id ) . ')' : '' ) . '</td>
2682
  <td>' . esc_html( stripslashes( $album['name'] ) ) . '</td>
2683
  <td><small>' . esc_html( stripslashes( $album['description'] ) ) . '</small></td>' .
2684
+ ( current_user_can( 'administrator' ) ? '<td>' . __( $album['owner'], 'wp-photo-album-plus' ) . '</td>' : '' ) . '
2685
  <td>' . $album['a_order'] . '</td>
2686
  <td>' . wppa_get_album_name( $album['a_parent'], array( 'extended' => true ) ) . '</td>
2687
  <td>' . $na . '/' . $np . '/' . $nm . '/' . $ns . '</td>
3333
  $result .= '
3334
  <td>' . esc_html( stripslashes( $album['name'] ) ) . '</td>
3335
  <td><small>' . esc_html( stripslashes( $album['description'] ) ) . '</small></td>' .
3336
+ ( current_user_can( 'administrator' ) ? '<td>' . __( $album['owner'], 'wp-photo-album-plus' ) . '</td>' : '' ) . '
3337
  <td>' . $album['a_order'] . '</td>
3338
+ <td>' . esc_html( stripslashes( wppa_get_album_name( $album['a_parent'], ['extended' => true] ) ) ) . '</td>
3339
  <td>' . $na . '/' . $np . '/' . $nm . '/' . $ns . '</td>';
3340
 
3341
  if ( wppa_have_access( $album['id'] ) ) {
wppa-album-covers.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Functions for album covers
6
- * Version 8.2.04.005
7
  *
8
  */
9
 
@@ -2115,7 +2115,7 @@ global $wpdb;
2115
  else {
2116
  wppa_out( '<li style="margin:0;cursor:pointer">' .
2117
  '<a' .
2118
- ( $href_content ? ' href="' . $href_content . '"' : '' ) .
2119
  ( $onclick_content ? ' onclick="' . $onclick_content . '"' : '' ) .
2120
  ' title="' . $title . '"' .
2121
  ' >' .
@@ -2134,7 +2134,7 @@ global $wpdb;
2134
  }
2135
  else {
2136
  wppa_out( '<a' .
2137
- ( $href_content ? ' href="' . $href_content . '"' : '' ) .
2138
  ( $onclick_content ? ' onclick="' . $onclick_content . '"' : '' ) .
2139
  ' title="' . $title . '"' .
2140
  ' >' .
@@ -2178,7 +2178,7 @@ global $wpdb;
2178
  }
2179
  else {
2180
  wppa_out( '<a' .
2181
- ( $href_content ? ' href="' . $href_content . '"' : '' ) .
2182
  ( $onclick_content ? ' onclick="' . $onclick_content . '"' : '' ) .
2183
  ' title="' . $title . '"' .
2184
  ' >' .
3
  * Package: wp-photo-album-plus
4
  *
5
  * Functions for album covers
6
+ * Version 8.2.04.007
7
  *
8
  */
9
 
2115
  else {
2116
  wppa_out( '<li style="margin:0;cursor:pointer">' .
2117
  '<a' .
2118
+ ( $href_content && ! $onclick_content ? ' href="' . $href_content . '"' : '' ) .
2119
  ( $onclick_content ? ' onclick="' . $onclick_content . '"' : '' ) .
2120
  ' title="' . $title . '"' .
2121
  ' >' .
2134
  }
2135
  else {
2136
  wppa_out( '<a' .
2137
+ ( $href_content && ! $onclick_content ? ' href="' . $href_content . '"' : '' ) .
2138
  ( $onclick_content ? ' onclick="' . $onclick_content . '"' : '' ) .
2139
  ' title="' . $title . '"' .
2140
  ' >' .
2178
  }
2179
  else {
2180
  wppa_out( '<a' .
2181
+ ( $href_content && ! $onclick_content ? ' href="' . $href_content . '"' : '' ) .
2182
  ( $onclick_content ? ' onclick="' . $onclick_content . '"' : '' ) .
2183
  ' title="' . $title . '"' .
2184
  ' >' .
wppa-functions.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Various functions
6
- * Version 8.2.04.005
7
  *
8
  */
9
 
@@ -1249,7 +1249,7 @@ global $albums_used;
1249
  }
1250
  else $albums = false;
1251
  }
1252
-
1253
  // Check for empty albums
1254
  if ( wppa_switch( 'skip_empty_albums' ) ) {
1255
  $user = wppa_get_user();
@@ -1261,10 +1261,12 @@ global $albums_used;
1261
  if ( ! $photocount && ! wppa_user_is( 'administrator' ) && $user != $albumowner ) unset( $albums[$albumkey] );
1262
  }
1263
  }
 
 
1264
 
1265
  // Check for album status
1266
  $albums = wppa_strip_void_albums( $albums );
1267
-
1268
  // Copy data into secondary cache
1269
  if ( $albums ) {
1270
  wppa_cache_album( 'add', $albums );
@@ -2042,8 +2044,9 @@ global $wppa_session;
2042
  }
2043
 
2044
  // Do query and return result after copy result to $thumbs!!
2045
- // wppa_log( 'dbg', 'Thumbs query = ' . $query );
2046
  $thumbs = wppa_do_get_thumbs_query( $query );
 
2047
  return $thumbs;
2048
  }
2049
 
@@ -2258,10 +2261,11 @@ global $photos_used;
2258
  if ( strlen( $query ) > 25000 ) {
2259
  wppa_log( 'war', 'Long query: ' . strlen($query) . ' chars. ' . substr( htmlspecialchars( $query ), 0, 100 ) . '...' , true );
2260
  }
2261
-
2262
  // Remove items because of status album
2263
  $thumbs = wppa_strip_void_photos( $thumbs );
2264
-
 
2265
  // Process extended duplicate removal
2266
  if ( $exduprem ) {
2267
  wppa_extended_duplicate_remove( $thumbs );
@@ -2390,7 +2394,7 @@ function wppa_extended_duplicate_remove( &$thumbs ) {
2390
  }
2391
 
2392
  $end = microtime( true );
2393
- wppa_log( 'dbg', sprintf( 'wppa_extended_duplicate_remove() took %5.3f seconds', $end - $start ) . ' and removed ' . $rem_cnt . ' items' );
2394
  }
2395
 
2396
  // Compare two items for equality
@@ -2515,9 +2519,9 @@ static $unique_ids;
2515
  }
2516
  if ( $score >= 4 ) return true;
2517
 
2518
- wppa_log( 'dbg', 'Items ' . $it1['id'] . ' and ' . $it2['id'] .
2519
- ' score only ' .
2520
- $score . ' matches' );
2521
 
2522
  // No match afterall
2523
  return false;
@@ -3117,7 +3121,7 @@ global $wppa_done;
3117
  }
3118
  }
3119
  else {
3120
- wppa_log( 'dbg', 'Comment to own photo ' . $photo );
3121
  }
3122
  }
3123
 
3
  * Package: wp-photo-album-plus
4
  *
5
  * Various functions
6
+ * Version 8.2.04.007
7
  *
8
  */
9
 
1249
  }
1250
  else $albums = false;
1251
  }
1252
+ /*
1253
  // Check for empty albums
1254
  if ( wppa_switch( 'skip_empty_albums' ) ) {
1255
  $user = wppa_get_user();
1261
  if ( ! $photocount && ! wppa_user_is( 'administrator' ) && $user != $albumowner ) unset( $albums[$albumkey] );
1262
  }
1263
  }
1264
+ */
1265
+ //if (wppa_get('album')=='344') wppa_log('obs', ' Aantal 2 = '. count($albums));
1266
 
1267
  // Check for album status
1268
  $albums = wppa_strip_void_albums( $albums );
1269
+ //if (wppa_get('album')=='344') wppa_log('obs', ' Aantal 3 = '. count($albums));
1270
  // Copy data into secondary cache
1271
  if ( $albums ) {
1272
  wppa_cache_album( 'add', $albums );
2044
  }
2045
 
2046
  // Do query and return result after copy result to $thumbs!!
2047
+
2048
  $thumbs = wppa_do_get_thumbs_query( $query );
2049
+ // wppa_log( 'dbg', 'Thumbs query = ' . $query .' count = '.count($thumbs));
2050
  return $thumbs;
2051
  }
2052
 
2261
  if ( strlen( $query ) > 25000 ) {
2262
  wppa_log( 'war', 'Long query: ' . strlen($query) . ' chars. ' . substr( htmlspecialchars( $query ), 0, 100 ) . '...' , true );
2263
  }
2264
+ $c1 = count( $thumbs );
2265
  // Remove items because of status album
2266
  $thumbs = wppa_strip_void_photos( $thumbs );
2267
+ $c2 = count( $thumbs );
2268
+ //wppa_log('obs', "Trimmed from $c1 tp $c2");
2269
  // Process extended duplicate removal
2270
  if ( $exduprem ) {
2271
  wppa_extended_duplicate_remove( $thumbs );
2394
  }
2395
 
2396
  $end = microtime( true );
2397
+ // wppa_log( 'dbg', sprintf( 'wppa_extended_duplicate_remove() took %5.3f seconds', $end - $start ) . ' and removed ' . $rem_cnt . ' items' );
2398
  }
2399
 
2400
  // Compare two items for equality
2519
  }
2520
  if ( $score >= 4 ) return true;
2521
 
2522
+ // wppa_log( 'dbg', 'Items ' . $it1['id'] . ' and ' . $it2['id'] .
2523
+ // ' score only ' .
2524
+ // $score . ' matches' );
2525
 
2526
  // No match afterall
2527
  return false;
3121
  }
3122
  }
3123
  else {
3124
+ // wppa_log( 'dbg', 'Comment to own photo ' . $photo );
3125
  }
3126
  }
3127
 
wppa-init.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * This file loads required php files and contains all functions used in init actions.
6
  *
7
- * Version 8.2.04.006
8
  */
9
 
10
  /* LOAD SIDEBAR WIDGETS */
@@ -548,6 +548,7 @@ global $wppa_album_gallery_texts_gallery;
548
  global $_gallery;
549
 
550
  if ( $wppa_skip_alb_to_gal ) {
 
551
  return $text;
552
  }
553
 
4
  *
5
  * This file loads required php files and contains all functions used in init actions.
6
  *
7
+ * Version 8.2.04.007
8
  */
9
 
10
  /* LOAD SIDEBAR WIDGETS */
548
  global $_gallery;
549
 
550
  if ( $wppa_skip_alb_to_gal ) {
551
+ $wppa_skip_alb_to_gal = false;
552
  return $text;
553
  }
554
 
wppa-items.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains functions to retrieve album and photo items
6
- * Version 8.2.04.006
7
  *
8
  */
9
 
@@ -200,9 +200,6 @@ global $wppa_skip_alb_to_gal;
200
  return $result;
201
  }
202
 
203
- // Prevent album to gallery 'translation'
204
- $wppa_skip_alb_to_gal = true;
205
-
206
  // Fill in the optional args
207
  $defaults = array( 'translate' => true,
208
  'addowner' => false,
@@ -216,6 +213,8 @@ global $wppa_skip_alb_to_gal;
216
  // Get data
217
  $thumb = wppa_cache_photo( $id );
218
  if ( $args['showname'] ) {
 
 
219
  $result .= __( stripslashes( $thumb['name'] ) , 'wp-photo-album-plus' );
220
  }
221
 
@@ -280,7 +279,6 @@ global $wppa_skip_alb_to_gal;
280
 
281
  // Translate keywords
282
  $result = str_replace( 'w#id', $id, $result );
283
- $wppa_skip_alb_to_gal = false;
284
 
285
  return wppa_utf8( $result );
286
  }
@@ -294,9 +292,6 @@ global $wppa_skip_alb_to_gal;
294
  return '';
295
  }
296
 
297
- // Prevent album to gallery 'translation'
298
- $wppa_skip_alb_to_gal = true;
299
-
300
  // Fill in the optional args
301
  $defaults = array( 'translate' => true,
302
  'doshortcodes' => false,
@@ -308,6 +303,7 @@ global $wppa_skip_alb_to_gal;
308
  $thumb = wppa_cache_photo( $id );
309
  $desc = $thumb['description']; // Raw data
310
  $desc = stripslashes( $desc ); // Unescape
 
311
  $desc = __( $desc , 'wp-photo-album-plus' ); // qTranslate
312
 
313
  // To prevent recursive rendering of scripts or shortcodes:
@@ -351,8 +347,6 @@ global $wppa_skip_alb_to_gal;
351
  }
352
  $desc = wppa_echo( $desc, '', '', true );
353
 
354
- $wppa_skip_alb_to_gal = false;
355
-
356
  return wppa_utf8( $desc );
357
  }
358
 
@@ -396,6 +390,7 @@ global $wpdb;
396
  $result = str_replace( 'w#exifdtm', $thumb['exifdtm'], $result );
397
  $keywords = array( 'name', 'filename', 'id', 'tags', 'views', 'album', 'dlcount' );
398
  foreach ( $keywords as $keyword ) {
 
399
  $replacement = __( trim( stripslashes( $thumb[$keyword] ) ) );
400
  if ( $keyword == 'tags' ) {
401
  $replacement = trim( $replacement, ',' );
@@ -490,6 +485,7 @@ global $wpdb;
490
  $custom = $thumb['custom'];
491
  $custom_data = $custom ? wppa_unserialize( $custom ) : array( '', '', '', '', '', '', '', '', '', '' );
492
  for ( $i = '0'; $i < '10'; $i++ ) {
 
493
  $rep = __( stripslashes( $custom_data[$i] ) ); // Replacement, qTranslate style translated
494
 
495
  // Patch for Rasada. Replace yyyy0101 by yyyy, yyyymmdd by yyyy.mm.dd
@@ -502,6 +498,7 @@ global $wpdb;
502
  }
503
  }
504
 
 
505
  $cap = __( wppa_opt( 'custom_caption_'.$i ) ); // Caption
506
  $dis = wppa_switch( 'custom_visible_'.$i ); // Visible
507
  if ( $rep == ', , ' ) $rep = '';
@@ -575,99 +572,57 @@ global $wppa_skip_alb_to_gal;
575
 
576
  // Init
577
  $album = $id > '0' ? wppa_cache_album( $id ) : false;
578
- $name = '';
579
 
580
  if ( $args['extended'] ) {
581
- if ( $id == '0' ) {
582
- if ( $args['translate'] ) {
583
- $name = __( '--- none ---', 'wp-photo-album-plus' );
584
- }
585
- else {
586
- $name = '--- none ---';
587
- }
588
- }
589
- if ( $id == '-1' ) {
590
- if ( $args['translate'] ) {
591
- $name = __( '--- separate ---', 'wp-photo-album-plus' );
592
- }
593
- else {
594
- $name = '--- separate ---';
595
- }
596
- }
597
- if ( $id == '-2' ) {
598
- if ( $args['translate'] ) {
599
- $name = __( '--- all ---', 'wp-photo-album-plus' );
600
- }
601
- else {
602
- $name = '--- all ---';
603
- }
604
- }
605
- if ( $id == '-3' ) {
606
- if ( $args['translate'] ) {
607
- $name = __( '--- owner/public ---', 'wp-photo-album-plus' );
608
- }
609
- else {
610
- $name = '--- owner/public ---';
611
- }
612
- }
613
- if ( $id <= '-9' ) {
614
- if ( $args['translate'] ) {
615
- $name = __( '--- deleted ---', 'wp-photo-album-plus' );
616
- }
617
- else {
618
- $name = '--- deleted ---';
619
- }
620
- }
621
- if ( $args['raw'] ) {
622
- $name = $album['name'];
623
  }
624
  }
625
  else {
626
- if ( $id == '-2' ) {
627
- if ( $args['translate'] ) {
628
- $name = __( 'All albums', 'wp-photo-album-plus' );
629
- }
630
- else {
631
- $name = 'All albums';
632
- }
633
- }
634
- if ( $id == '-3' ) {
635
- if ( $args['translate'] ) {
636
- $name = __( 'My and public albums', 'wp-photo-album-plus' );
637
- }
638
- else {
639
- $name = 'My and public albums';
640
- }
641
  }
642
  }
643
 
644
- if ( ! $id ) return '';
645
- elseif ( $id <= '-9' ) {
646
- return '';
647
- }
648
- elseif ( ! is_numeric( $id ) || $id < '1' ) {
649
- return '';
650
  }
651
- else {
652
- if ( ! $album ) {
653
- if ( $args['translate'] ) {
654
- $name = __( '--- deleted ---', 'wp-photo-album-plus' );
655
- }
656
- else {
657
- $name = '--- deleted ---';
658
- }
659
  }
660
  else {
661
- if ( $args['translate'] ) {
662
- $wppa_skip_alb_to_gal = true;
663
- $name = __( stripslashes( $album['name'] ) );
664
- $wppa_skip_alb_to_gal = false;
665
- }
666
- else {
667
- $name = stripslashes( $album['name'] );
668
- }
669
  }
670
- }
671
 
672
  // To prevent recursive rendering of scripts or shortcodes:
673
  $name = str_replace( array( '%%wppa%%', '[wppa', '[/wppa]' ), array( '%-wppa-%', '{wppa', '{/wppa}' ), $name );
@@ -718,7 +673,6 @@ global $wppa_skip_alb_to_gal;
718
  // qTranslate, wpGlobus
719
  $wppa_skip_alb_to_gal = true;
720
  $desc = __( $desc );
721
- $wppa_skip_alb_to_gal = false;
722
  }
723
 
724
  // Enable or strip html
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains functions to retrieve album and photo items
6
+ * Version 8.2.04.007
7
  *
8
  */
9
 
200
  return $result;
201
  }
202
 
 
 
 
203
  // Fill in the optional args
204
  $defaults = array( 'translate' => true,
205
  'addowner' => false,
213
  // Get data
214
  $thumb = wppa_cache_photo( $id );
215
  if ( $args['showname'] ) {
216
+
217
+ $wppa_skip_alb_to_gal = true;
218
  $result .= __( stripslashes( $thumb['name'] ) , 'wp-photo-album-plus' );
219
  }
220
 
279
 
280
  // Translate keywords
281
  $result = str_replace( 'w#id', $id, $result );
 
282
 
283
  return wppa_utf8( $result );
284
  }
292
  return '';
293
  }
294
 
 
 
 
295
  // Fill in the optional args
296
  $defaults = array( 'translate' => true,
297
  'doshortcodes' => false,
303
  $thumb = wppa_cache_photo( $id );
304
  $desc = $thumb['description']; // Raw data
305
  $desc = stripslashes( $desc ); // Unescape
306
+ $wppa_skip_alb_to_gal = true;
307
  $desc = __( $desc , 'wp-photo-album-plus' ); // qTranslate
308
 
309
  // To prevent recursive rendering of scripts or shortcodes:
347
  }
348
  $desc = wppa_echo( $desc, '', '', true );
349
 
 
 
350
  return wppa_utf8( $desc );
351
  }
352
 
390
  $result = str_replace( 'w#exifdtm', $thumb['exifdtm'], $result );
391
  $keywords = array( 'name', 'filename', 'id', 'tags', 'views', 'album', 'dlcount' );
392
  foreach ( $keywords as $keyword ) {
393
+ $wppa_skip_alb_to_gal = true;
394
  $replacement = __( trim( stripslashes( $thumb[$keyword] ) ) );
395
  if ( $keyword == 'tags' ) {
396
  $replacement = trim( $replacement, ',' );
485
  $custom = $thumb['custom'];
486
  $custom_data = $custom ? wppa_unserialize( $custom ) : array( '', '', '', '', '', '', '', '', '', '' );
487
  for ( $i = '0'; $i < '10'; $i++ ) {
488
+ $wppa_skip_alb_to_gal = true;
489
  $rep = __( stripslashes( $custom_data[$i] ) ); // Replacement, qTranslate style translated
490
 
491
  // Patch for Rasada. Replace yyyy0101 by yyyy, yyyymmdd by yyyy.mm.dd
498
  }
499
  }
500
 
501
+ $wppa_skip_alb_to_gal = true;
502
  $cap = __( wppa_opt( 'custom_caption_'.$i ) ); // Caption
503
  $dis = wppa_switch( 'custom_visible_'.$i ); // Visible
504
  if ( $rep == ', , ' ) $rep = '';
572
 
573
  // Init
574
  $album = $id > '0' ? wppa_cache_album( $id ) : false;
 
575
 
576
  if ( $args['extended'] ) {
577
+ switch( $id ) {
578
+ case '0':
579
+ return __( '--- none ---', 'wp-photo-album-plus' );
580
+ break;
581
+ case '-1':
582
+ return __( '--- separate ---', 'wp-photo-album-plus' );
583
+ break;
584
+ case '-2':
585
+ return __( '--- all ---', 'wp-photo-album-plus' );
586
+ break;
587
+ case '-3':
588
+ return __( '--- public ---', 'wp-photo-album-plus' );
589
+ break;
590
+ default:
591
+ if ( $id <= '-9' ) {
592
+ return __( '--- deleted ---', 'wp-photo-album-plus' );
593
+ break;
594
+ }
595
+ if ( $args['raw'] ) {
596
+ return $album['name'];
597
+ }
598
+ break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
599
  }
600
  }
601
  else {
602
+ switch( $id ) {
603
+ case '-2':
604
+ return __( 'All albums', 'wp-photo-album-plus' );
605
+ break;
606
+ case '-3':
607
+ return __( 'My and public albums', 'wp-photo-album-plus' );
608
+ break;
609
+ default:
610
+ if ( ! is_numeric( $id ) || ! $id || $id < '1' ) return '';
 
 
 
 
 
 
611
  }
612
  }
613
 
614
+ if ( ! $album ) {
615
+ return __( '--- deleted ---', 'wp-photo-album-plus' );
 
 
 
 
616
  }
617
+ else {
618
+ if ( $args['translate'] ) {
619
+ $wppa_skip_alb_to_gal = true;
620
+ $name = __( stripslashes( $album['name'] ) );
 
 
 
 
621
  }
622
  else {
623
+ $name = stripslashes( $album['name'] );
 
 
 
 
 
 
 
624
  }
625
+ }
626
 
627
  // To prevent recursive rendering of scripts or shortcodes:
628
  $name = str_replace( array( '%%wppa%%', '[wppa', '[/wppa]' ), array( '%-wppa-%', '{wppa', '{/wppa}' ), $name );
673
  // qTranslate, wpGlobus
674
  $wppa_skip_alb_to_gal = true;
675
  $desc = __( $desc );
 
676
  }
677
 
678
  // Enable or strip html
wppa-statistics.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * Functions for counts etc
6
  * Common use front and admin
7
- * Version 8.2.04.006
8
  *
9
  */
10
 
@@ -698,93 +698,72 @@ global $wpdb;
698
  }
699
 
700
  // See if an album is visible to the current user. This takes 'skip empty albums' into account.
701
- function wppa_is_album_visible( $id, $strict = false ) {
702
  global $wpdb;
703
- static $cache;
 
 
704
 
705
  // Validate arg
706
- if ( ! wppa_is_int( $id ) ) {
707
  wppa_log( 'err', 'Invalid arg in wppa_is_album_visible: '.serialize($id) );
708
  return false;
709
  }
710
 
711
- // Init cache
712
- if ( ! is_array( $cache ) ) {
713
- $cache = array();
714
- }
 
 
715
 
716
- // In cache?
717
- if ( isset( $cache[$id] ) ) {
718
- return $cache[$id];
719
- }
720
-
721
- // Everything is visible for admin and superusers
722
- if ( wppa_user_is( 'administrator' ) ) {
723
- $cache[$id] = true;
724
  return true;
725
  }
726
 
727
- // Album is alwaus visible for the owner
728
- $user = wppa_get_user();
729
- $album = wppa_cache_album( $id );
730
- if ( is_array( $album ) ) { // Album exists
731
- if ( $user == $album['owner'] ) {
732
- $cache[$id] = true;
733
- return true;
734
- }
735
- }
736
- else { // Album does not exist
737
- $cache[$id] = false;
738
- return false;
739
- }
740
-
741
- // Look at album status
742
- switch( $album['status'] ) {
743
  case 'hidden':
744
- $cache[$id] = false;
745
  return false;
746
  break;
747
  case 'private':
748
- if ( ! is_user_logged_in() ) {
749
- $cache[$id] = false;
750
  return false;
751
  }
752
  break;
753
-
754
- default:
755
- // Depends on skip switch and content
756
  }
757
 
758
- // Look at skip switch
759
- if ( ! wppa_switch( 'skip_empty_albums' ) ) {
760
- $cache[$id] = true;
761
- return true;
762
- }
763
 
764
- // Look at photos, only if not strict to prevent endless loop
765
- if ( ! $strict ) {
766
  $photos = $wpdb->get_col( $wpdb->prepare( "SELECT id FROM $wpdb->wppa_photos WHERE album = %s", $id ) );
767
  foreach( $photos as $p ) {
768
 
769
- if ( wppa_is_photo_visible( $p, 'strict' ) ) {
770
- $cache[$id] = true;
771
- return true;
772
  }
773
  }
774
- }
775
 
776
- // Look at subalbums
777
- $albs = $wpdb->get_results( $wpdb->prepare( "SELECT id, status FROM $wpdb->wppa_albums WHERE a_parent = %s", $id ), ARRAY_A );
778
- foreach( $albs as $alb ) {
779
 
780
- if ( wppa_is_album_visible( $alb['id'] ) ) {
781
- $cache[$id] = true;
782
- return true;
783
  }
784
  }
 
 
 
785
 
786
- $cache[$id] = false;
787
- return false; // This album is not visible for the current user
788
  }
789
 
790
  // Get number of visible 1st generation albums
@@ -793,6 +772,10 @@ function wppa_get_visible_album_count( $id ) {
793
 
794
  $result = '0';
795
 
 
 
 
 
796
  $albs = wppa_get_sub_album_ids( $id );
797
  if ( $albs ) {
798
  foreach( $albs as $alb ) {
@@ -830,29 +813,26 @@ static $cache;
830
  }
831
 
832
  // Find out if a given photo is visible for the current user
833
- function wppa_is_photo_visible( $id, $strict = false ) {
 
 
 
834
 
835
  // Validate arg
836
- if ( ! wppa_is_int( $id ) ) {
837
  wppa_log( 'err', 'Invalid arg in wppa_is_photo_visible: '.serialize($id) );
838
  return false;
839
  }
840
 
841
- // Get the photo data
842
- $p = wppa_cache_photo( $id );
843
- if ( ! $p ) {
844
- return false; // Photo does not exist
845
- }
846
-
847
- // Photo can only be visible when in a visible album
848
- if ( ! $strict ) {
849
- if ( ! wppa_is_album_visible( $p['album'], 'strict' ) ) {
850
- return false;
851
- }
852
- }
853
 
854
  // Dispatch on photo status
855
- switch( $p['status'] ) {
856
  case 'publish': // A published photo found, visible to every one
857
  case 'featured':
858
  case 'gold':
@@ -861,14 +841,13 @@ function wppa_is_photo_visible( $id, $strict = false ) {
861
  return true;
862
  break;
863
  case 'private':
864
- if ( is_user_logged_in() ) { // A logged in user may see private photos
865
  return true;
866
  }
867
  break;
868
  case 'pending': // Pending and scheduled may be seen by owner
869
  case 'scheduled':
870
- $user = wppa_get_user();
871
- if ( $user == $p['owner'] ) {
872
  return true;
873
  }
874
  break;
@@ -890,6 +869,10 @@ static $cache;
890
  return $cache[$id];
891
  }
892
 
 
 
 
 
893
  if ( wppa_user_is( 'administrator' ) ) {
894
  $result = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE album = %s", $id ) );
895
  }
4
  *
5
  * Functions for counts etc
6
  * Common use front and admin
7
+ * Version 8.2.04.007
8
  *
9
  */
10
 
698
  }
699
 
700
  // See if an album is visible to the current user. This takes 'skip empty albums' into account.
701
+ function wppa_is_album_visible( $id ) {
702
  global $wpdb;
703
+ static $user;
704
+ static $admin;
705
+ static $login;
706
 
707
  // Validate arg
708
+ if ( ! wppa_is_int( $id ) || $id < '1' || ! wppa_cache_album( $id ) ) {
709
  wppa_log( 'err', 'Invalid arg in wppa_is_album_visible: '.serialize($id) );
710
  return false;
711
  }
712
 
713
+ // Get usefull data
714
+ $status = wppa_get_album_item( $id, 'status' );
715
+ $owner = wppa_get_album_item( $id, 'owner' );
716
+ if ( $user === NULL ) $user = wppa_get_user();
717
+ if ( $admin === NULL ) $admin = wppa_user_is( 'administrator' );
718
+ if ( $login === NULL ) $login = is_user_logged_in();
719
 
720
+ // Always visible for admin and owner
721
+ if ( $admin || $user == $owner ) {
 
 
 
 
 
 
722
  return true;
723
  }
724
 
725
+ // Dispaych on status
726
+ switch( $status ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
727
  case 'hidden':
 
728
  return false;
729
  break;
730
  case 'private':
731
+ if ( ! $login ) {
 
732
  return false;
733
  }
734
  break;
735
+ default: // case 'publish':
736
+ break;
 
737
  }
738
 
739
+ // The user is logged in or the status is publish
740
+ // Dispatch on whether we skip empty albums
741
+ if ( wppa_switch( 'skip_empty_albums' ) ) {
 
 
742
 
743
+ // Look at photos
 
744
  $photos = $wpdb->get_col( $wpdb->prepare( "SELECT id FROM $wpdb->wppa_photos WHERE album = %s", $id ) );
745
  foreach( $photos as $p ) {
746
 
747
+ if ( wppa_is_photo_visible( $p ) ) {
748
+ return true; // Found at least one
 
749
  }
750
  }
 
751
 
752
+ // Look at subalbums
753
+ $albs = $wpdb->get_col( $wpdb->prepare( "SELECT id FROM $wpdb->wppa_albums WHERE a_parent = %s", $id ) );
754
+ foreach( $albs as $a ) {
755
 
756
+ if ( wppa_is_album_visible( $a ) ) {
757
+ return true; // Found at least one
758
+ }
759
  }
760
  }
761
+ else {
762
+ return true;
763
+ }
764
 
765
+ // This album is empty and therefor not visible for the current user
766
+ return false;
767
  }
768
 
769
  // Get number of visible 1st generation albums
772
 
773
  $result = '0';
774
 
775
+ if ( ! wppa_is_album_visible( $id ) ) {
776
+ return '0';
777
+ }
778
+
779
  $albs = wppa_get_sub_album_ids( $id );
780
  if ( $albs ) {
781
  foreach( $albs as $alb ) {
813
  }
814
 
815
  // Find out if a given photo is visible for the current user
816
+ function wppa_is_photo_visible( $id ) {
817
+ static $user;
818
+ static $admin;
819
+ static $login;
820
 
821
  // Validate arg
822
+ if ( ! wppa_is_int( $id ) || $id < '0' || ! wppa_cache_photo( $id ) ) {
823
  wppa_log( 'err', 'Invalid arg in wppa_is_photo_visible: '.serialize($id) );
824
  return false;
825
  }
826
 
827
+ // Get usefull data
828
+ $status = wppa_get_photo_item( $id, 'status' );
829
+ $owner = wppa_get_photo_item( $id, 'owner' );
830
+ if ( $user === NULL ) $user = wppa_get_user();
831
+ if ( $admin === NULL ) $admin = wppa_user_is( 'administrator' );
832
+ if ( $login === NULL ) $login = is_user_logged_in();
 
 
 
 
 
 
833
 
834
  // Dispatch on photo status
835
+ switch( $status ) {
836
  case 'publish': // A published photo found, visible to every one
837
  case 'featured':
838
  case 'gold':
841
  return true;
842
  break;
843
  case 'private':
844
+ if ( $login ) { // A logged in user may see private photos
845
  return true;
846
  }
847
  break;
848
  case 'pending': // Pending and scheduled may be seen by owner
849
  case 'scheduled':
850
+ if ( $admin || $owner == $user ) {
 
851
  return true;
852
  }
853
  break;
869
  return $cache[$id];
870
  }
871
 
872
+ if ( ! wppa_is_album_visible( $id ) ) {
873
+ return '0';
874
+ }
875
+
876
  if ( wppa_user_is( 'administrator' ) ) {
877
  $result = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE album = %s", $id ) );
878
  }
wppa.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  * Plugin Name: WP Photo Album Plus
4
  * Description: Easily manage and display your photo albums and slideshows within your WordPress site.
5
- * Version: 8.2.04.006
6
  * Author: J.N. Breetvelt a.k.a. OpaJaap
7
  * Author URI: http://wppa.opajaap.nl/
8
  * Plugin URI: http://wordpress.org/extend/plugins/wp-photo-album-plus/
@@ -24,7 +24,7 @@ global $wp_version;
24
 
25
  /* WPPA GLOBALS */
26
  global $wppa_api_version;
27
- $wppa_api_version = '8.2.04.006'; // WPPA software version
28
  global $wppa_revno;
29
  $wppa_revno = str_replace( '.', '', $wppa_api_version ); // WPPA db version
30
 
2
  /*
3
  * Plugin Name: WP Photo Album Plus
4
  * Description: Easily manage and display your photo albums and slideshows within your WordPress site.
5
+ * Version: 8.2.04.007
6
  * Author: J.N. Breetvelt a.k.a. OpaJaap
7
  * Author URI: http://wppa.opajaap.nl/
8
  * Plugin URI: http://wordpress.org/extend/plugins/wp-photo-album-plus/
24
 
25
  /* WPPA GLOBALS */
26
  global $wppa_api_version;
27
+ $wppa_api_version = '8.2.04.007'; // WPPA software version
28
  global $wppa_revno;
29
  $wppa_revno = str_replace( '.', '', $wppa_api_version ); // WPPA db version
30