Groups - Version 2.3.0

Version Description

  • Tested with WordPress 4.8.
  • Fixed a REST API access restriction issue, added the filter rest_prepare_{$post_type} to grant or deny access to individual posts.
  • Updated the translation template.
  • German translation updated.
  • Updated the appearance of the network settings.
  • Updated the table creation process dropping use of dbDelta() due to its restrictions (can't handle IF NOT EXISTS).
  • Fixed an issue related to cache and switching to a blog when neither wp_cache_switch_to_blog() nor wp_cache_reset() are implemented, like in WP Engine's object-cache.php which does provide wp_cache_flush().
  • Guarded against concurrent execution of multiple instances of plugin activation and deactivation processes.
  • Fixed an attempt to refresh capabilities when no previous version was installed.
Download this release

Release Info

Developer itthinx
Plugin Icon 128x128 Groups
Version 2.3.0
Comparing to
See all releases

Code changes from version 2.2.0 to 2.3.0

changelog.txt CHANGED
@@ -1,5 +1,18 @@
1
  == Groups by itthinx - changelog.txt ==
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  = 2.2.0 =
4
  * Important change in this version: If access restrictions for post type are disabled, related entries will not be protected anymore.
5
  * Improved the activation performance by simplifying the creation of user-group entries.
1
  == Groups by itthinx - changelog.txt ==
2
 
3
+ = 2.3.0 =
4
+ * Tested with WordPress 4.8.
5
+ * Fixed a REST API access restriction issue, added the filter rest_prepare_{$post_type} to
6
+ grant or deny access to individual posts.
7
+ * Updated the translation template.
8
+ * German translation updated.
9
+ * Updated the appearance of the network settings.
10
+ * Updated the table creation process dropping use of dbDelta() due to its restrictions (can't handle IF NOT EXISTS).
11
+ * Fixed an issue related to cache and switching to a blog when neither wp_cache_switch_to_blog() nor wp_cache_reset()
12
+ are implemented, like in WP Engine's object-cache.php which does provide wp_cache_flush().
13
+ * Guarded against concurrent execution of multiple instances of plugin activation and deactivation processes.
14
+ * Fixed an attempt to refresh capabilities when no previous version was installed.
15
+
16
  = 2.2.0 =
17
  * Important change in this version: If access restrictions for post type are disabled, related entries will not be protected anymore.
18
  * Improved the activation performance by simplifying the creation of user-group entries.
groups.php CHANGED
@@ -21,7 +21,7 @@
21
  * Plugin Name: Groups
22
  * Plugin URI: http://www.itthinx.com/plugins/groups
23
  * Description: Groups provides group-based user membership management, group-based capabilities and content access control.
24
- * Version: 2.2.0
25
  * Author: itthinx
26
  * Author URI: http://www.itthinx.com
27
  * Donate-Link: http://www.itthinx.com
@@ -32,7 +32,7 @@
32
  if ( !defined( 'ABSPATH' ) ) {
33
  exit;
34
  }
35
- define( 'GROUPS_CORE_VERSION', '2.2.0' );
36
  define( 'GROUPS_FILE', __FILE__ );
37
  if ( !defined( 'GROUPS_CORE_DIR' ) ) {
38
  define( 'GROUPS_CORE_DIR', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
21
  * Plugin Name: Groups
22
  * Plugin URI: http://www.itthinx.com/plugins/groups
23
  * Description: Groups provides group-based user membership management, group-based capabilities and content access control.
24
+ * Version: 2.3.0
25
  * Author: itthinx
26
  * Author URI: http://www.itthinx.com
27
  * Donate-Link: http://www.itthinx.com
32
  if ( !defined( 'ABSPATH' ) ) {
33
  exit;
34
  }
35
+ define( 'GROUPS_CORE_VERSION', '2.3.0' );
36
  define( 'GROUPS_FILE', __FILE__ );
37
  if ( !defined( 'GROUPS_CORE_DIR' ) ) {
38
  define( 'GROUPS_CORE_DIR', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
languages/groups-de_DE.mo CHANGED
Binary file
languages/groups-de_DE.po CHANGED
@@ -7,8 +7,8 @@ msgid ""
7
  msgstr ""
8
  "Project-Id-Version: \n"
9
  "Report-Msgid-Bugs-To: \n"
10
- "POT-Creation-Date: 2017-05-13 17:14+0200\n"
11
- "PO-Revision-Date: 2017-05-13 17:22+0200\n"
12
  "Last-Translator: Karim\n"
13
  "Language-Team: itthinx.com\n"
14
  "Language: de_DE\n"
@@ -34,7 +34,7 @@ msgstr "— Ohne Änderung —"
34
  msgid "(only unrestricted)"
35
  msgstr "(ohne Beschränkung)"
36
 
37
- #: lib/admin/class-groups-admin-users.php:374
38
  msgid "--"
39
  msgstr "--"
40
 
@@ -389,6 +389,13 @@ msgstr ""
389
  "Klicken zum Umschalten, ob gewährende Gruppen zu den Kapazitäten angezeigt "
390
  "werden."
391
 
 
 
 
 
 
 
 
392
  #: lib/admin/groups-admin-options.php:286
393
  msgid "Deactivation and data persistence"
394
  msgstr "Deaktivierung und Datenpersistenz"
@@ -453,7 +460,7 @@ msgstr "Legacy Zugriffsbeschränkungen basierend auf Kapazitäten aktivieren."
453
 
454
  #: lib/admin/groups-admin-options.php:207
455
  msgid "Enabling this on production sites is <strong>not</strong> recommended."
456
- msgstr ""
457
 
458
  #: legacy/access/class-groups-access-meta-boxes-legacy.php:204
459
  #: legacy/access/class-groups-access-meta-boxes-legacy.php:505
@@ -482,7 +489,7 @@ msgstr ""
482
  msgid "Example:"
483
  msgstr "Beispiel:"
484
 
485
- #: lib/admin/class-groups-admin-users.php:275
486
  msgid "Filter"
487
  msgstr "Filtern"
488
 
@@ -550,14 +557,14 @@ msgstr "Gruppenname : %s"
550
  #: lib/admin/class-groups-admin-user-profile.php:72
551
  #: lib/admin/class-groups-admin-user-profile.php:135
552
  #: lib/admin/class-groups-admin-user-profile.php:159
553
- #: lib/admin/class-groups-admin-users.php:347
554
  #: lib/admin/class-groups-admin.php:245 lib/admin/class-groups-admin.php:246
555
  #: lib/admin/class-groups-admin.php:275 lib/core/class-groups-help.php:63
556
  #: lib/core/class-groups-help.php:68 lib/core/class-groups-help.php:69
557
  msgid "Groups"
558
  msgstr "Groups"
559
 
560
- #: lib/admin/class-groups-admin-post-columns.php:93
561
  msgctxt "Column header"
562
  msgid "Groups"
563
  msgstr "Gruppen"
@@ -623,6 +630,10 @@ msgstr ""
623
  "Hier können Sie Gruppen <strong>hinzufügen</strong>, <strong>bearbeiten</"
624
  "strong> und <strong>löschen</strong>."
625
 
 
 
 
 
626
  #: lib/admin/groups-admin-capabilities.php:313
627
  #: lib/admin/groups-admin-groups.php:303
628
  msgid "ID"
@@ -688,6 +699,10 @@ msgstr ""
688
  msgid "Inherited capabilities:"
689
  msgstr "Geerbte Kapazitäten:"
690
 
 
 
 
 
691
  #: lib/admin/class-groups-admin-welcome.php:158
692
  msgid ""
693
  "It seems that you have updated from Groups 1.x where access restrictions "
@@ -723,6 +738,10 @@ msgstr ""
723
  msgid "Log out"
724
  msgstr "Abmelden"
725
 
 
 
 
 
726
  #: legacy/access/class-groups-access-meta-boxes-legacy.php:503
727
  #: lib/access/class-groups-access-meta-boxes.php:411
728
  msgid "Media"
@@ -845,7 +864,7 @@ msgstr[1] "%d Kapazitäten wurden hinzugefügt."
845
  msgid "One or more capabilities required to read the entry."
846
  msgstr "Eine oder mehr Kapazitäten sind benötigt um den Beitrag zu lesen."
847
 
848
- #: lib/admin/class-groups-admin-post-columns.php:92
849
  msgid "One or more groups granting access to entries."
850
  msgstr "Eine oder mehr Gruppen die Zugriff auf Einträge erstatten."
851
 
@@ -1255,7 +1274,7 @@ msgstr ""
1255
  "Dies bedeutet dass vorige Zugangsbeschränkungen die auf Kapazitäten basieren "
1256
  "immer noch die Einträge schützen."
1257
 
1258
- #: lib/access/class-groups-post-access.php:508
1259
  msgid ""
1260
  "This method is deprecated. You should use Groups_Post_Access_Legacy::"
1261
  "get_read_post_capabilities() to retrieve the capabilities instead."
@@ -1268,6 +1287,9 @@ msgid ""
1268
  "To disable, do not define the constant <code>GROUPS_ADMINISTRATOR_OVERRIDE</"
1269
  "code> or set it to <code>false</code>."
1270
  msgstr ""
 
 
 
1271
 
1272
  #: lib/admin/class-groups-admin-welcome.php:206
1273
  msgid ""
@@ -1364,7 +1386,7 @@ msgstr "Den Begrüßungsbildschirm für diese Version von Groups anzeigen"
1364
 
1365
  #: lib/admin/class-groups-admin.php:302
1366
  msgid "Warning!"
1367
- msgstr ""
1368
 
1369
  #: lib/admin/class-groups-admin-welcome.php:172
1370
  msgid "We have made it even easier to protect your content!"
@@ -1399,6 +1421,10 @@ msgstr ""
1399
  "groups/\">Dokumentation</a> anzusehen um mehr darüber zu erfahren wie man es "
1400
  "verwendet."
1401
 
 
 
 
 
1402
  #: lib/views/class-groups-shortcodes.php:527
1403
  #, php-format
1404
  msgid "You are a member of the %s group."
@@ -1420,6 +1446,17 @@ msgstr ""
1420
  "Das System läuft mit Legacy Zugriffsbeschränkungen basierend auf Kapazitäten "
1421
  "aktiviert."
1422
 
 
 
 
 
 
 
 
 
 
 
 
1423
  #: legacy/access/class-groups-access-meta-boxes-legacy.php:312
1424
  msgid ""
1425
  "You can create a new group and capability here. The capability will be "
@@ -1510,7 +1547,7 @@ msgstr ""
1510
  "Man benötigt die entsprechenden Rechte um Zugriffsbeschränkungen setzen zu "
1511
  "können."
1512
 
1513
- #: lib/access/class-groups-post-access.php:383
1514
  msgid ""
1515
  "You should use Groups_Post_Access_Legacy::create() to pass a capability "
1516
  "restriction instead."
7
  msgstr ""
8
  "Project-Id-Version: \n"
9
  "Report-Msgid-Bugs-To: \n"
10
+ "POT-Creation-Date: 2017-06-28 12:56+0200\n"
11
+ "PO-Revision-Date: 2017-06-28 13:03+0200\n"
12
  "Last-Translator: Karim\n"
13
  "Language-Team: itthinx.com\n"
14
  "Language: de_DE\n"
34
  msgid "(only unrestricted)"
35
  msgstr "(ohne Beschränkung)"
36
 
37
+ #: lib/admin/class-groups-admin-users.php:378
38
  msgid "--"
39
  msgstr "--"
40
 
389
  "Klicken zum Umschalten, ob gewährende Gruppen zu den Kapazitäten angezeigt "
390
  "werden."
391
 
392
+ #: lib/admin/class-groups-admin-notice.php:102
393
+ msgid ""
394
+ "Could you please spare a minute and give it a review over at WordPress.org?"
395
+ msgstr ""
396
+ "Könnten Sie bitte eine Minute freimachen und eine Rezension auf WordPress."
397
+ "org abgeben?"
398
+
399
  #: lib/admin/groups-admin-options.php:286
400
  msgid "Deactivation and data persistence"
401
  msgstr "Deaktivierung und Datenpersistenz"
460
 
461
  #: lib/admin/groups-admin-options.php:207
462
  msgid "Enabling this on production sites is <strong>not</strong> recommended."
463
+ msgstr "Es wird empfohlen dies nicht auf öffentlichen Seiten zu aktivieren."
464
 
465
  #: legacy/access/class-groups-access-meta-boxes-legacy.php:204
466
  #: legacy/access/class-groups-access-meta-boxes-legacy.php:505
489
  msgid "Example:"
490
  msgstr "Beispiel:"
491
 
492
+ #: lib/admin/class-groups-admin-users.php:279
493
  msgid "Filter"
494
  msgstr "Filtern"
495
 
557
  #: lib/admin/class-groups-admin-user-profile.php:72
558
  #: lib/admin/class-groups-admin-user-profile.php:135
559
  #: lib/admin/class-groups-admin-user-profile.php:159
560
+ #: lib/admin/class-groups-admin-users.php:351
561
  #: lib/admin/class-groups-admin.php:245 lib/admin/class-groups-admin.php:246
562
  #: lib/admin/class-groups-admin.php:275 lib/core/class-groups-help.php:63
563
  #: lib/core/class-groups-help.php:68 lib/core/class-groups-help.php:69
564
  msgid "Groups"
565
  msgstr "Groups"
566
 
567
+ #: lib/admin/class-groups-admin-post-columns.php:96
568
  msgctxt "Column header"
569
  msgid "Groups"
570
  msgstr "Gruppen"
630
  "Hier können Sie Gruppen <strong>hinzufügen</strong>, <strong>bearbeiten</"
631
  "strong> und <strong>löschen</strong>."
632
 
633
+ #: lib/admin/class-groups-admin-notice.php:114
634
+ msgid "I have already done that."
635
+ msgstr "Das habe ich bereits getan."
636
+
637
  #: lib/admin/groups-admin-capabilities.php:313
638
  #: lib/admin/groups-admin-groups.php:303
639
  msgid "ID"
699
  msgid "Inherited capabilities:"
700
  msgstr "Geerbte Kapazitäten:"
701
 
702
+ #: lib/access/class-groups-post-access.php:150
703
+ msgid "Invalid post ID."
704
+ msgstr "Ungültige Beitrags-ID."
705
+
706
  #: lib/admin/class-groups-admin-welcome.php:158
707
  msgid ""
708
  "It seems that you have updated from Groups 1.x where access restrictions "
738
  msgid "Log out"
739
  msgstr "Abmelden"
740
 
741
+ #: lib/admin/class-groups-admin-notice.php:100
742
+ msgid "Many thanks for using <strong>Groups</strong>!"
743
+ msgstr "Vielen Dank das Sie <strong>Groups</strong> verwenden!"
744
+
745
  #: legacy/access/class-groups-access-meta-boxes-legacy.php:503
746
  #: lib/access/class-groups-access-meta-boxes.php:411
747
  msgid "Media"
864
  msgid "One or more capabilities required to read the entry."
865
  msgstr "Eine oder mehr Kapazitäten sind benötigt um den Beitrag zu lesen."
866
 
867
+ #: lib/admin/class-groups-admin-post-columns.php:95
868
  msgid "One or more groups granting access to entries."
869
  msgstr "Eine oder mehr Gruppen die Zugriff auf Einträge erstatten."
870
 
1274
  "Dies bedeutet dass vorige Zugangsbeschränkungen die auf Kapazitäten basieren "
1275
  "immer noch die Einträge schützen."
1276
 
1277
+ #: lib/access/class-groups-post-access.php:584
1278
  msgid ""
1279
  "This method is deprecated. You should use Groups_Post_Access_Legacy::"
1280
  "get_read_post_capabilities() to retrieve the capabilities instead."
1287
  "To disable, do not define the constant <code>GROUPS_ADMINISTRATOR_OVERRIDE</"
1288
  "code> or set it to <code>false</code>."
1289
  msgstr ""
1290
+ "Um dies zu deaktivieren, sollte die Konstante "
1291
+ "<code>GROUPS_ADMINISTRATOR_OVERRIDE</code> nicht definiert werden oder auf "
1292
+ "<code>false</code> gesetzt werden."
1293
 
1294
  #: lib/admin/class-groups-admin-welcome.php:206
1295
  msgid ""
1386
 
1387
  #: lib/admin/class-groups-admin.php:302
1388
  msgid "Warning!"
1389
+ msgstr "Achtung!"
1390
 
1391
  #: lib/admin/class-groups-admin-welcome.php:172
1392
  msgid "We have made it even easier to protect your content!"
1421
  "groups/\">Dokumentation</a> anzusehen um mehr darüber zu erfahren wie man es "
1422
  "verwendet."
1423
 
1424
+ #: lib/admin/class-groups-admin-notice.php:108
1425
+ msgid "Yes, here we go!"
1426
+ msgstr "Ja, auf geht’s!"
1427
+
1428
  #: lib/views/class-groups-shortcodes.php:527
1429
  #, php-format
1430
  msgid "You are a member of the %s group."
1446
  "Das System läuft mit Legacy Zugriffsbeschränkungen basierend auf Kapazitäten "
1447
  "aktiviert."
1448
 
1449
+ #: lib/admin/class-groups-admin-notice.php:119
1450
+ #, php-format
1451
+ msgid ""
1452
+ "You can also follow <a href=\"%s\">@itthinx</a> on Twitter or visit <a href="
1453
+ "\"%s\" target=\"_blank\">itthinx.com</a> to check out other free and premium "
1454
+ "plugins we provide."
1455
+ msgstr ""
1456
+ "Sie können auch <a href=\"%s\">@itthinx</a> auf Twitter folgen oder <a href="
1457
+ "\"%s\" target=\"_blank\">itthinx.com</a> um mehr über weitere kostenfreie "
1458
+ "und Premium Plugins die wir bereitstellen zu erfahren."
1459
+
1460
  #: legacy/access/class-groups-access-meta-boxes-legacy.php:312
1461
  msgid ""
1462
  "You can create a new group and capability here. The capability will be "
1547
  "Man benötigt die entsprechenden Rechte um Zugriffsbeschränkungen setzen zu "
1548
  "können."
1549
 
1550
+ #: lib/access/class-groups-post-access.php:459
1551
  msgid ""
1552
  "You should use Groups_Post_Access_Legacy::create() to pass a capability "
1553
  "restriction instead."
languages/groups.pot CHANGED
@@ -7,7 +7,7 @@
7
  msgid ""
8
  msgstr "Project-Id-Version: PACKAGE VERSION\n"
9
  "Report-Msgid-Bugs-To: \n"
10
- "POT-Creation-Date: 2017-05-12 14:20+0200\n"
11
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
  "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -33,7 +33,7 @@ msgstr ""
33
  msgid "(only unrestricted)"
34
  msgstr ""
35
 
36
- #: lib/admin/class-groups-admin-users.php:374
37
  msgid "--"
38
  msgstr ""
39
 
@@ -346,6 +346,11 @@ msgstr ""
346
  msgid "Click to toggle the display of groups that grant the capabilities."
347
  msgstr ""
348
 
 
 
 
 
 
349
  #: lib/admin/groups-admin-options.php:286
350
  msgid "Deactivation and data persistence"
351
  msgstr ""
@@ -424,7 +429,7 @@ msgstr ""
424
  msgid "Example:"
425
  msgstr ""
426
 
427
- #: lib/admin/class-groups-admin-users.php:275
428
  msgid "Filter"
429
  msgstr ""
430
 
@@ -481,14 +486,14 @@ msgstr ""
481
  #: lib/admin/class-groups-admin-user-profile.php:72
482
  #: lib/admin/class-groups-admin-user-profile.php:135
483
  #: lib/admin/class-groups-admin-user-profile.php:159
484
- #: lib/admin/class-groups-admin-users.php:347
485
  #: lib/admin/class-groups-admin.php:245 lib/admin/class-groups-admin.php:246
486
  #: lib/admin/class-groups-admin.php:275 lib/core/class-groups-help.php:63
487
  #: lib/core/class-groups-help.php:68 lib/core/class-groups-help.php:69
488
  msgid "Groups"
489
  msgstr ""
490
 
491
- #: lib/admin/class-groups-admin-post-columns.php:93
492
  msgctxt "Column header"
493
  msgid "Groups"
494
  msgstr ""
@@ -548,6 +553,10 @@ msgid "Here you can <strong>add</strong>, <strong>edit</strong> and "
548
  "<strong>remove</strong> groups."
549
  msgstr ""
550
 
 
 
 
 
551
  #: lib/admin/groups-admin-capabilities.php:313
552
  #: lib/admin/groups-admin-groups.php:303
553
  msgid "ID"
@@ -594,6 +603,10 @@ msgstr ""
594
  msgid "Inherited capabilities:"
595
  msgstr ""
596
 
 
 
 
 
597
  #: lib/admin/class-groups-admin-welcome.php:158
598
  msgid "It seems that you have updated from Groups 1.x where access "
599
  "restrictions were based on capabilities."
@@ -623,6 +636,10 @@ msgstr ""
623
  msgid "Log out"
624
  msgstr ""
625
 
 
 
 
 
626
  #: legacy/access/class-groups-access-meta-boxes-legacy.php:503
627
  #: lib/access/class-groups-access-meta-boxes.php:411
628
  msgid "Media"
@@ -725,7 +742,7 @@ msgstr[1] ""
725
  msgid "One or more capabilities required to read the entry."
726
  msgstr ""
727
 
728
- #: lib/admin/class-groups-admin-post-columns.php:92
729
  msgid "One or more groups granting access to entries."
730
  msgstr ""
731
 
@@ -1083,7 +1100,7 @@ msgid "This means that if you had access restrictions in place that were "
1083
  "based on capabilities, your entries will still be protected."
1084
  msgstr ""
1085
 
1086
- #: lib/access/class-groups-post-access.php:508
1087
  msgid "This method is deprecated. You should use Groups_Post_Access_Legacy::"
1088
  "get_read_post_capabilities() to retrieve the capabilities instead."
1089
  msgstr ""
@@ -1195,6 +1212,10 @@ msgid "Whether you are new to Groups or have been using it before, please "
1195
  "about how to use it."
1196
  msgstr ""
1197
 
 
 
 
 
1198
  #: lib/views/class-groups-shortcodes.php:527
1199
  #, php-format
1200
  msgid "You are a member of the %s group."
@@ -1210,6 +1231,13 @@ msgid "You are running the system with legacy access control based on "
1210
  "capabilities enabled."
1211
  msgstr ""
1212
 
 
 
 
 
 
 
 
1213
  #: legacy/access/class-groups-access-meta-boxes-legacy.php:312
1214
  msgid "You can create a new group and capability here. The capability will "
1215
  "be assigned to the group and enabled to enforce read access. Group "
@@ -1273,7 +1301,7 @@ msgstr ""
1273
  msgid "You need to have permission to set access restrictions."
1274
  msgstr ""
1275
 
1276
- #: lib/access/class-groups-post-access.php:383
1277
  msgid "You should use Groups_Post_Access_Legacy::create() to pass a "
1278
  "capability restriction instead."
1279
  msgstr ""
7
  msgid ""
8
  msgstr "Project-Id-Version: PACKAGE VERSION\n"
9
  "Report-Msgid-Bugs-To: \n"
10
+ "POT-Creation-Date: 2017-06-28 12:49+0200\n"
11
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
  "Language-Team: LANGUAGE <LL@li.org>\n"
33
  msgid "(only unrestricted)"
34
  msgstr ""
35
 
36
+ #: lib/admin/class-groups-admin-users.php:378
37
  msgid "--"
38
  msgstr ""
39
 
346
  msgid "Click to toggle the display of groups that grant the capabilities."
347
  msgstr ""
348
 
349
+ #: lib/admin/class-groups-admin-notice.php:102
350
+ msgid "Could you please spare a minute and give it a review over at "
351
+ "WordPress.org?"
352
+ msgstr ""
353
+
354
  #: lib/admin/groups-admin-options.php:286
355
  msgid "Deactivation and data persistence"
356
  msgstr ""
429
  msgid "Example:"
430
  msgstr ""
431
 
432
+ #: lib/admin/class-groups-admin-users.php:279
433
  msgid "Filter"
434
  msgstr ""
435
 
486
  #: lib/admin/class-groups-admin-user-profile.php:72
487
  #: lib/admin/class-groups-admin-user-profile.php:135
488
  #: lib/admin/class-groups-admin-user-profile.php:159
489
+ #: lib/admin/class-groups-admin-users.php:351
490
  #: lib/admin/class-groups-admin.php:245 lib/admin/class-groups-admin.php:246
491
  #: lib/admin/class-groups-admin.php:275 lib/core/class-groups-help.php:63
492
  #: lib/core/class-groups-help.php:68 lib/core/class-groups-help.php:69
493
  msgid "Groups"
494
  msgstr ""
495
 
496
+ #: lib/admin/class-groups-admin-post-columns.php:96
497
  msgctxt "Column header"
498
  msgid "Groups"
499
  msgstr ""
553
  "<strong>remove</strong> groups."
554
  msgstr ""
555
 
556
+ #: lib/admin/class-groups-admin-notice.php:114
557
+ msgid "I have already done that."
558
+ msgstr ""
559
+
560
  #: lib/admin/groups-admin-capabilities.php:313
561
  #: lib/admin/groups-admin-groups.php:303
562
  msgid "ID"
603
  msgid "Inherited capabilities:"
604
  msgstr ""
605
 
606
+ #: lib/access/class-groups-post-access.php:150
607
+ msgid "Invalid post ID."
608
+ msgstr ""
609
+
610
  #: lib/admin/class-groups-admin-welcome.php:158
611
  msgid "It seems that you have updated from Groups 1.x where access "
612
  "restrictions were based on capabilities."
636
  msgid "Log out"
637
  msgstr ""
638
 
639
+ #: lib/admin/class-groups-admin-notice.php:100
640
+ msgid "Many thanks for using <strong>Groups</strong>!"
641
+ msgstr ""
642
+
643
  #: legacy/access/class-groups-access-meta-boxes-legacy.php:503
644
  #: lib/access/class-groups-access-meta-boxes.php:411
645
  msgid "Media"
742
  msgid "One or more capabilities required to read the entry."
743
  msgstr ""
744
 
745
+ #: lib/admin/class-groups-admin-post-columns.php:95
746
  msgid "One or more groups granting access to entries."
747
  msgstr ""
748
 
1100
  "based on capabilities, your entries will still be protected."
1101
  msgstr ""
1102
 
1103
+ #: lib/access/class-groups-post-access.php:584
1104
  msgid "This method is deprecated. You should use Groups_Post_Access_Legacy::"
1105
  "get_read_post_capabilities() to retrieve the capabilities instead."
1106
  msgstr ""
1212
  "about how to use it."
1213
  msgstr ""
1214
 
1215
+ #: lib/admin/class-groups-admin-notice.php:108
1216
+ msgid "Yes, here we go!"
1217
+ msgstr ""
1218
+
1219
  #: lib/views/class-groups-shortcodes.php:527
1220
  #, php-format
1221
  msgid "You are a member of the %s group."
1231
  "capabilities enabled."
1232
  msgstr ""
1233
 
1234
+ #: lib/admin/class-groups-admin-notice.php:119
1235
+ #, php-format
1236
+ msgid "You can also follow <a href=\"%s\">@itthinx</a> on Twitter or visit "
1237
+ "<a href=\"%s\" target=\"_blank\">itthinx.com</a> to check out other "
1238
+ "free and premium plugins we provide."
1239
+ msgstr ""
1240
+
1241
  #: legacy/access/class-groups-access-meta-boxes-legacy.php:312
1242
  msgid "You can create a new group and capability here. The capability will "
1243
  "be assigned to the group and enabled to enforce read access. Group "
1301
  msgid "You need to have permission to set access restrictions."
1302
  msgstr ""
1303
 
1304
+ #: lib/access/class-groups-post-access.php:459
1305
  msgid "You should use Groups_Post_Access_Legacy::create() to pass a "
1306
  "capability restriction instead."
1307
  msgstr ""
lib/access/class-groups-post-access.php CHANGED
@@ -111,6 +111,47 @@ class Groups_Post_Access {
111
  add_filter( 'wp_count_posts', array( __CLASS__, 'wp_count_posts' ), 10, 3 );
112
  // @todo enable the filter and implement below if needed to correct attachment counts
113
  // add_filter( 'wp_count_attachments', array( __CLASS__, 'wp_count_attachments' ), 10, 2 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  }
115
 
116
  /**
111
  add_filter( 'wp_count_posts', array( __CLASS__, 'wp_count_posts' ), 10, 3 );
112
  // @todo enable the filter and implement below if needed to correct attachment counts
113
  // add_filter( 'wp_count_attachments', array( __CLASS__, 'wp_count_attachments' ), 10, 2 );
114
+
115
+ // REST API
116
+ $post_types = self::get_handles_post_types();
117
+ if ( !empty( $post_types ) ) {
118
+ foreach( $post_types as $post_type => $handles ) {
119
+ if ( $handles ) {
120
+ add_filter( "rest_prepare_{$post_type}", array( __CLASS__, 'rest_prepare_post' ), 10, 3 );
121
+ }
122
+ }
123
+ }
124
+ }
125
+
126
+ /**
127
+ * Replicates the response for invalid post IDs when unauthorized access to a post is requested.
128
+ * There is no filter in WP_REST_Posts_Controller::get_post() nor in get_post() that we could use (WP 4.8).
129
+ *
130
+ * REST API Handbook https://developer.wordpress.org/rest-api/
131
+ *
132
+ * For development tests:
133
+ *
134
+ * 1. Install https://github.com/WP-API/Basic-Auth
135
+ * 2. Protect post 1 with group "Test".
136
+ * 3. Test access denied: $ curl http://example.com/wp-json/wp/v2/posts/1
137
+ * 4. Test access granted $ curl --user username:password https://example.com/wp-json/wp/v2/posts/1
138
+ *
139
+ * On #4 username:password are cleartext, username must belong to group "Test".
140
+ *
141
+ * @param array $response
142
+ * @param WP_Post $post
143
+ * @param string $request
144
+ * @return string[]|number[][]
145
+ */
146
+ public static function rest_prepare_post( $response, $post, $request ) {
147
+ if ( isset( $post->ID ) && !self::user_can_read_post( $post->ID ) ) {
148
+ $response = array(
149
+ 'code' => 'rest_post_invalid_id',
150
+ 'message' => __( 'Invalid post ID.' ),
151
+ 'data' => array( 'status' => 404 )
152
+ );
153
+ }
154
+ return $response;
155
  }
156
 
157
  /**
lib/admin/groups-admin-options.php CHANGED
@@ -355,15 +355,18 @@ function groups_network_admin_options() {
355
  '<div>' .
356
  '<h2>' . __( 'Network deactivation and data persistence', 'groups' ) . '</h2>' .
357
  '<p>' .
 
358
  '<input name="delete-data" type="checkbox" ' . ( $delete_data ? 'checked="checked"' : '' ) . '/>' .
359
- '<label for="delete-data">' . __( 'Delete all Groups plugin data for ALL sites on network deactivation', 'groups' ) . '</label>' .
 
 
360
  '</p>' .
361
  '<p class="description warning">' .
362
  __( 'CAUTION: If this option is active while the plugin is deactivated, ALL plugin settings and data will be DELETED for <strong>all sites</strong>. If you are going to use this option, now would be a good time to make a backup. By enabling this option you agree to be solely responsible for any loss of data or any other consequences thereof.', 'groups' ) .
363
  '</p>' .
364
  '<p>' .
365
  wp_nonce_field( 'admin', GROUPS_ADMIN_OPTIONS_NONCE, true, false ) .
366
- '<input type="submit" name="submit" value="' . __( 'Save', 'groups' ) . '"/>' .
367
  '</p>' .
368
  '</div>' .
369
  '</form>';
355
  '<div>' .
356
  '<h2>' . __( 'Network deactivation and data persistence', 'groups' ) . '</h2>' .
357
  '<p>' .
358
+ '<label>' .
359
  '<input name="delete-data" type="checkbox" ' . ( $delete_data ? 'checked="checked"' : '' ) . '/>' .
360
+ ' ' .
361
+ __( 'Delete all Groups plugin data for ALL sites on network deactivation', 'groups' ) .
362
+ '</label>' .
363
  '</p>' .
364
  '<p class="description warning">' .
365
  __( 'CAUTION: If this option is active while the plugin is deactivated, ALL plugin settings and data will be DELETED for <strong>all sites</strong>. If you are going to use this option, now would be a good time to make a backup. By enabling this option you agree to be solely responsible for any loss of data or any other consequences thereof.', 'groups' ) .
366
  '</p>' .
367
  '<p>' .
368
  wp_nonce_field( 'admin', GROUPS_ADMIN_OPTIONS_NONCE, true, false ) .
369
+ '<input class="button button-primary" type="submit" name="submit" value="' . __( 'Save', 'groups' ) . '"/>' .
370
  '</p>' .
371
  '</div>' .
372
  '</form>';
lib/core/class-groups-controller.php CHANGED
@@ -36,9 +36,16 @@ class Groups_Controller {
36
 
37
  /**
38
  * Cache-safe switching in case any multi-site hiccups might occur.
 
39
  * Clears the cache after switching to the given blog to avoid using
40
  * another blog's cached values.
 
 
 
 
41
  * See wp_cache_reset() in wp-includes/cache.php
 
 
42
  * @see wp_cache_reset()
43
  * @link http://core.trac.wordpress.org/ticket/14941
44
  *
@@ -48,7 +55,9 @@ class Groups_Controller {
48
  switch_to_blog( $blog_id );
49
  if ( function_exists( 'wp_cache_switch_to_blog' ) ) {
50
  wp_cache_switch_to_blog( $blog_id ); // introduced in WP 3.5.0
51
- } else {
 
 
52
  wp_cache_reset(); // deprecated in WP 3.5.0
53
  }
54
  }
@@ -168,16 +177,23 @@ class Groups_Controller {
168
  * @param boolean $network_wide
169
  */
170
  public static function activate( $network_wide = false ) {
171
- if ( is_multisite() && $network_wide ) {
172
- $blog_ids = Groups_Utility::get_blogs();
173
- foreach ( $blog_ids as $blog_id ) {
174
- self::switch_to_blog( $blog_id );
 
 
 
 
 
 
175
  self::setup();
176
- self::restore_current_blog();
 
 
 
 
177
  }
178
- } else {
179
- self::setup();
180
- set_transient( 'groups_plugin_activated', true, 60 );
181
  }
182
  }
183
 
@@ -201,7 +217,7 @@ class Groups_Controller {
201
  // create tables
202
  $group_table = _groups_get_tablename( 'group' );
203
  if ( $wpdb->get_var( "SHOW TABLES LIKE '$group_table'" ) != $group_table ) {
204
- $queries[] = "CREATE TABLE $group_table (
205
  group_id BIGINT(20) UNSIGNED NOT NULL auto_increment,
206
  parent_id BIGINT(20) DEFAULT NULL,
207
  creator_id BIGINT(20) DEFAULT NULL,
@@ -214,7 +230,7 @@ class Groups_Controller {
214
  }
215
  $capability_table = _groups_get_tablename( 'capability' );
216
  if ( $wpdb->get_var( "SHOW TABLES LIKE '$capability_table'" ) != $capability_table ) {
217
- $queries[] = "CREATE TABLE $capability_table (
218
  capability_id BIGINT(20) UNSIGNED NOT NULL auto_increment,
219
  capability VARCHAR(255) NOT NULL,
220
  class VARCHAR(255) DEFAULT NULL,
@@ -228,7 +244,7 @@ class Groups_Controller {
228
  }
229
  $user_group_table = _groups_get_tablename( 'user_group' );
230
  if ( $wpdb->get_var( "SHOW TABLES LIKE '$user_group_table'" ) != $user_group_table ) {
231
- $queries[] = "CREATE TABLE $user_group_table (
232
  user_id bigint(20) unsigned NOT NULL,
233
  group_id bigint(20) unsigned NOT NULL,
234
  PRIMARY KEY (user_id, group_id),
@@ -237,7 +253,7 @@ class Groups_Controller {
237
  }
238
  $user_capability_table = _groups_get_tablename( 'user_capability' );
239
  if ( $wpdb->get_var( "SHOW TABLES LIKE '$user_capability_table'" ) != $user_capability_table ) {
240
- $queries[] = "CREATE TABLE $user_capability_table (
241
  user_id bigint(20) unsigned NOT NULL,
242
  capability_id bigint(20) unsigned NOT NULL,
243
  PRIMARY KEY (user_id, capability_id),
@@ -246,7 +262,7 @@ class Groups_Controller {
246
  }
247
  $group_capability_table = _groups_get_tablename( 'group_capability' );
248
  if ( $wpdb->get_var( "SHOW TABLES LIKE '$group_capability_table'" ) != $group_capability_table ) {
249
- $queries[] = "CREATE TABLE $group_capability_table (
250
  group_id bigint(20) unsigned NOT NULL,
251
  capability_id bigint(20) unsigned NOT NULL,
252
  PRIMARY KEY (group_id, capability_id),
@@ -254,8 +270,14 @@ class Groups_Controller {
254
  ) $charset_collate;";
255
  }
256
  if ( !empty( $queries ) ) {
257
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
258
- dbDelta( $queries );
 
 
 
 
 
 
259
  }
260
  // needs to be called to create its capabilities
261
  Groups_Post_Access::activate();
@@ -304,56 +326,62 @@ class Groups_Controller {
304
  * Update maintenance.
305
  */
306
  public static function update( $previous_version ) {
 
307
  global $wpdb, $groups_admin_messages;
 
308
  $result = true;
309
- $queries = array();
310
- switch ( $previous_version ) {
311
- case '1.0.0' :
312
- $capability_table = _groups_get_tablename( 'capability' );
313
- if ( $wpdb->get_var( "SHOW TABLES LIKE '$capability_table'" ) == $capability_table ) {
314
- // increase column sizes
315
- $queries[] = "ALTER TABLE $capability_table MODIFY capability VARCHAR(255) UNIQUE NOT NULL;";
316
- $queries[] = "ALTER TABLE $capability_table MODIFY class VARCHAR(255) DEFAULT NULL;";
317
- $queries[] = "ALTER TABLE $capability_table MODIFY object VARCHAR(255) DEFAULT NULL;";
318
- // correct capabilities
319
- $queries[] = "UPDATE $capability_table SET capability='delete_published_pages' WHERE capability='delete_published_pag';";
320
- $queries[] = "UPDATE $capability_table SET capability='delete_published_posts' WHERE capability='delete_published_pos';";
321
- // fix hideously big index
322
- $queries[] = "ALTER TABLE $capability_table DROP INDEX capability_kco;";
323
- $queries[] = "ALTER TABLE $capability_table ADD INDEX capability_kco (capability(20),class(20),object(20));";
324
- }
325
- break;
326
- case '1.0.0-beta-3d' :
327
- $capability_table = _groups_get_tablename( 'capability' );
328
- if ( $wpdb->get_var( "SHOW TABLES LIKE '$capability_table'" ) == $capability_table ) {
329
- // increase column sizes
330
- $queries[] = "ALTER TABLE $capability_table MODIFY capability VARCHAR(255) UNIQUE NOT NULL;";
331
- $queries[] = "ALTER TABLE $capability_table MODIFY class VARCHAR(255) DEFAULT NULL;";
332
- $queries[] = "ALTER TABLE $capability_table MODIFY object VARCHAR(255) DEFAULT NULL;";
333
- // correct capabilities
334
- $queries[] = "UPDATE $capability_table SET capability='delete_published_pages' WHERE capability='delete_published_pag';";
335
- $queries[] = "UPDATE $capability_table SET capability='delete_published_posts' WHERE capability='delete_published_pos';";
336
- }
337
- break;
338
- default :
339
- if ( !empty( $previous_version ) ) {
340
- if ( version_compare( $previous_version, '1.1.6' ) < 0 ) {
341
- Groups_Options::update_option( Groups_Post_Access::READ_POST_CAPABILITIES, array( Groups_Post_Access::READ_POST_CAPABILITY ) );
342
- $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->postmeta SET meta_value = %s WHERE meta_key = %s", Groups_Post_Access::READ_POST_CAPABILITY, Groups_Post_Access::POSTMETA_PREFIX . Groups_Post_Access::READ_POST_CAPABILITY ) );
343
  }
344
- if ( version_compare( $previous_version, '1.5.1' ) < 0 ) {
345
- $capability_table = _groups_get_tablename( 'capability' );
346
- $queries[] = "ALTER TABLE $capability_table DROP INDEX capability, ADD UNIQUE INDEX capability(capability(100));";
 
 
 
 
 
 
 
 
347
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
348
  }
349
- } // switch
350
- if ( version_compare( $previous_version, '2.0.0' ) < 0 ) {
351
- self::set_default_capabilities();
352
- Groups_WordPress::refresh_capabilities();
353
- }
354
- foreach ( $queries as $query ) {
355
- if ( $wpdb->query( $query ) === false ) {
356
- $result = false;
357
  }
358
  }
359
  return $result;
@@ -365,17 +393,24 @@ class Groups_Controller {
365
  * @param boolean $network_wide
366
  */
367
  public static function deactivate( $network_wide = false ) {
368
- if ( is_multisite() && $network_wide ) {
369
- if ( Groups_Options::get_option( 'groups_network_delete_data', false ) ) {
370
- $blog_ids = Groups_Utility::get_blogs();
371
- foreach ( $blog_ids as $blog_id ) {
372
- self::switch_to_blog( $blog_id );
373
- self::cleanup( true );
374
- self::restore_current_blog();
 
 
 
375
  }
 
 
 
 
 
 
376
  }
377
- } else {
378
- self::cleanup();
379
  }
380
  }
381
 
@@ -465,5 +500,99 @@ class Groups_Controller {
465
  }
466
  }
467
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
468
  }
469
  Groups_Controller::boot();
36
 
37
  /**
38
  * Cache-safe switching in case any multi-site hiccups might occur.
39
+ *
40
  * Clears the cache after switching to the given blog to avoid using
41
  * another blog's cached values.
42
+ *
43
+ * Some implementations don't have wp_cache_switch_to_blog() nor the deprecated
44
+ * wp_cache_reset(), e.g. WP Engine's object-cache.php which has wp_cache_flush().
45
+ *
46
  * See wp_cache_reset() in wp-includes/cache.php
47
+ * @see wp_cache_switch_to_blog()
48
+ * @see wp_cache_flush()
49
  * @see wp_cache_reset()
50
  * @link http://core.trac.wordpress.org/ticket/14941
51
  *
55
  switch_to_blog( $blog_id );
56
  if ( function_exists( 'wp_cache_switch_to_blog' ) ) {
57
  wp_cache_switch_to_blog( $blog_id ); // introduced in WP 3.5.0
58
+ } else if ( function_exists( 'wp_cache_flush' ) ) {
59
+ wp_cache_flush();
60
+ } else if ( function_exists( 'wp_cache_reset' ) ) {
61
  wp_cache_reset(); // deprecated in WP 3.5.0
62
  }
63
  }
177
  * @param boolean $network_wide
178
  */
179
  public static function activate( $network_wide = false ) {
180
+ $sem_id = self::sem_get( self::get_sem_key() );
181
+ if ( ( $sem_id === false ) || self::sem_acquire( $sem_id ) ) {
182
+ if ( is_multisite() && $network_wide ) {
183
+ $blog_ids = Groups_Utility::get_blogs();
184
+ foreach ( $blog_ids as $blog_id ) {
185
+ self::switch_to_blog( $blog_id );
186
+ self::setup();
187
+ self::restore_current_blog();
188
+ }
189
+ } else {
190
  self::setup();
191
+ set_transient( 'groups_plugin_activated', true, 60 );
192
+ }
193
+ if ( $sem_id !== false ) {
194
+ self::sem_release( $sem_id );
195
+ self::sem_remove( $sem_id );
196
  }
 
 
 
197
  }
198
  }
199
 
217
  // create tables
218
  $group_table = _groups_get_tablename( 'group' );
219
  if ( $wpdb->get_var( "SHOW TABLES LIKE '$group_table'" ) != $group_table ) {
220
+ $queries[] = "CREATE TABLE IF NOT EXISTS $group_table (
221
  group_id BIGINT(20) UNSIGNED NOT NULL auto_increment,
222
  parent_id BIGINT(20) DEFAULT NULL,
223
  creator_id BIGINT(20) DEFAULT NULL,
230
  }
231
  $capability_table = _groups_get_tablename( 'capability' );
232
  if ( $wpdb->get_var( "SHOW TABLES LIKE '$capability_table'" ) != $capability_table ) {
233
+ $queries[] = "CREATE TABLE IF NOT EXISTS $capability_table (
234
  capability_id BIGINT(20) UNSIGNED NOT NULL auto_increment,
235
  capability VARCHAR(255) NOT NULL,
236
  class VARCHAR(255) DEFAULT NULL,
244
  }
245
  $user_group_table = _groups_get_tablename( 'user_group' );
246
  if ( $wpdb->get_var( "SHOW TABLES LIKE '$user_group_table'" ) != $user_group_table ) {
247
+ $queries[] = "CREATE TABLE IF NOT EXISTS $user_group_table (
248
  user_id bigint(20) unsigned NOT NULL,
249
  group_id bigint(20) unsigned NOT NULL,
250
  PRIMARY KEY (user_id, group_id),
253
  }
254
  $user_capability_table = _groups_get_tablename( 'user_capability' );
255
  if ( $wpdb->get_var( "SHOW TABLES LIKE '$user_capability_table'" ) != $user_capability_table ) {
256
+ $queries[] = "CREATE TABLE IF NOT EXISTS $user_capability_table (
257
  user_id bigint(20) unsigned NOT NULL,
258
  capability_id bigint(20) unsigned NOT NULL,
259
  PRIMARY KEY (user_id, capability_id),
262
  }
263
  $group_capability_table = _groups_get_tablename( 'group_capability' );
264
  if ( $wpdb->get_var( "SHOW TABLES LIKE '$group_capability_table'" ) != $group_capability_table ) {
265
+ $queries[] = "CREATE TABLE IF NOT EXISTS $group_capability_table (
266
  group_id bigint(20) unsigned NOT NULL,
267
  capability_id bigint(20) unsigned NOT NULL,
268
  PRIMARY KEY (group_id, capability_id),
270
  ) $charset_collate;";
271
  }
272
  if ( !empty( $queries ) ) {
273
+ // For the record ... (and https://core.trac.wordpress.org/ticket/12773 should not be closed)
274
+ // dbDelta() fails to handle queries "CREATE TABLE IF NOT EXISTS ..."
275
+ // (a regex results in "IF" used as array index holding only last query to create table).
276
+ //require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
277
+ //dbDelta( $queries );
278
+ foreach( $queries as $query ) {
279
+ $wpdb->query( $query );
280
+ }
281
  }
282
  // needs to be called to create its capabilities
283
  Groups_Post_Access::activate();
326
  * Update maintenance.
327
  */
328
  public static function update( $previous_version ) {
329
+
330
  global $wpdb, $groups_admin_messages;
331
+
332
  $result = true;
333
+
334
+ $sem_id = self::sem_get( self::get_sem_key() );
335
+ if ( ( $sem_id === false ) || self::sem_acquire( $sem_id ) ) {
336
+ $queries = array();
337
+ switch ( $previous_version ) {
338
+ case '1.0.0' :
339
+ $capability_table = _groups_get_tablename( 'capability' );
340
+ if ( $wpdb->get_var( "SHOW TABLES LIKE '$capability_table'" ) == $capability_table ) {
341
+ // increase column sizes
342
+ $queries[] = "ALTER TABLE $capability_table MODIFY capability VARCHAR(255) UNIQUE NOT NULL;";
343
+ $queries[] = "ALTER TABLE $capability_table MODIFY class VARCHAR(255) DEFAULT NULL;";
344
+ $queries[] = "ALTER TABLE $capability_table MODIFY object VARCHAR(255) DEFAULT NULL;";
345
+ // correct capabilities
346
+ $queries[] = "UPDATE $capability_table SET capability='delete_published_pages' WHERE capability='delete_published_pag';";
347
+ $queries[] = "UPDATE $capability_table SET capability='delete_published_posts' WHERE capability='delete_published_pos';";
348
+ // fix hideously big index
349
+ $queries[] = "ALTER TABLE $capability_table DROP INDEX capability_kco;";
350
+ $queries[] = "ALTER TABLE $capability_table ADD INDEX capability_kco (capability(20),class(20),object(20));";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
351
  }
352
+ break;
353
+ case '1.0.0-beta-3d' :
354
+ $capability_table = _groups_get_tablename( 'capability' );
355
+ if ( $wpdb->get_var( "SHOW TABLES LIKE '$capability_table'" ) == $capability_table ) {
356
+ // increase column sizes
357
+ $queries[] = "ALTER TABLE $capability_table MODIFY capability VARCHAR(255) UNIQUE NOT NULL;";
358
+ $queries[] = "ALTER TABLE $capability_table MODIFY class VARCHAR(255) DEFAULT NULL;";
359
+ $queries[] = "ALTER TABLE $capability_table MODIFY object VARCHAR(255) DEFAULT NULL;";
360
+ // correct capabilities
361
+ $queries[] = "UPDATE $capability_table SET capability='delete_published_pages' WHERE capability='delete_published_pag';";
362
+ $queries[] = "UPDATE $capability_table SET capability='delete_published_posts' WHERE capability='delete_published_pos';";
363
  }
364
+ break;
365
+ default :
366
+ if ( !empty( $previous_version ) ) {
367
+ if ( version_compare( $previous_version, '1.1.6' ) < 0 ) {
368
+ Groups_Options::update_option( Groups_Post_Access::READ_POST_CAPABILITIES, array( Groups_Post_Access::READ_POST_CAPABILITY ) );
369
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->postmeta SET meta_value = %s WHERE meta_key = %s", Groups_Post_Access::READ_POST_CAPABILITY, Groups_Post_Access::POSTMETA_PREFIX . Groups_Post_Access::READ_POST_CAPABILITY ) );
370
+ }
371
+ if ( version_compare( $previous_version, '1.5.1' ) < 0 ) {
372
+ $capability_table = _groups_get_tablename( 'capability' );
373
+ $queries[] = "ALTER TABLE $capability_table DROP INDEX capability, ADD UNIQUE INDEX capability(capability(100));";
374
+ }
375
+ }
376
+ } // switch
377
+ if ( !empty( $previous_version ) && version_compare( $previous_version, '2.0.0' ) < 0 ) {
378
+ self::set_default_capabilities();
379
+ Groups_WordPress::refresh_capabilities();
380
+ }
381
+ foreach ( $queries as $query ) {
382
+ if ( $wpdb->query( $query ) === false ) {
383
+ $result = false;
384
  }
 
 
 
 
 
 
 
 
385
  }
386
  }
387
  return $result;
393
  * @param boolean $network_wide
394
  */
395
  public static function deactivate( $network_wide = false ) {
396
+ $sem_id = self::sem_get( self::get_sem_key() );
397
+ if ( ( $sem_id === false ) || self::sem_acquire( $sem_id ) ) {
398
+ if ( is_multisite() && $network_wide ) {
399
+ if ( Groups_Options::get_option( 'groups_network_delete_data', false ) ) {
400
+ $blog_ids = Groups_Utility::get_blogs();
401
+ foreach ( $blog_ids as $blog_id ) {
402
+ self::switch_to_blog( $blog_id );
403
+ self::cleanup( true );
404
+ self::restore_current_blog();
405
+ }
406
  }
407
+ } else {
408
+ self::cleanup();
409
+ }
410
+ if ( $sem_id !== false ) {
411
+ self::sem_release( $sem_id );
412
+ self::sem_remove( $sem_id );
413
  }
 
 
414
  }
415
  }
416
 
500
  }
501
  }
502
 
503
+ /**
504
+ * Guarded sem_get() wrapper.
505
+ *
506
+ * @see sem_get()
507
+ *
508
+ * @param int $key
509
+ * @param number $max_acquire
510
+ * @param number $perm
511
+ * @param number $auto_release
512
+ * @return boolean|resource
513
+ */
514
+ private static function sem_get( $key, $max_acquire = 1, $perm = 0666, $auto_release = 1 ) {
515
+ $result = false;
516
+ if ( function_exists( 'sem_get' ) ) {
517
+ $result = sem_get( $key, $max_acquire, $perm, $auto_release );
518
+ }
519
+ return $result;
520
+ }
521
+
522
+ /**
523
+ * Guarded sem_acquire() wrapper.
524
+ *
525
+ * To maintain backwards-compatibility with servers running PHP < 5.6 where
526
+ * the second parameter to sem_acquire() is not supported, we use sem_remove()
527
+ * and have any calls waiting on sem_acquire() fail silently (achieving that
528
+ * the activation, update or deactivation routines are not run for those
529
+ * processes that have been waiting and which would have duplicated execution
530
+ * unnecessarily).
531
+ *
532
+ * @see sem_acquire()
533
+ *
534
+ * @param resource $sem_identifier
535
+ * @param string $nowait (only taken into account and effective on PHP >= 5.6.1)
536
+ * @return boolean
537
+ */
538
+ private static function sem_acquire( $sem_identifier, $nowait = false ) {
539
+ $result = false;
540
+ if ( function_exists( 'sem_acquire' ) ) {
541
+ if ( version_compare( phpversion(), '5.6.1' ) >= 0 ) {
542
+ $result = @sem_acquire( $sem_identifier, $nowait );
543
+ } else {
544
+ $result = @sem_acquire( $sem_identifier );
545
+ }
546
+ }
547
+ return $result;
548
+ }
549
+
550
+ /**
551
+ * Guarded sem_release() wrapper.
552
+ *
553
+ * @see sem_release()
554
+ *
555
+ * @param resource $sem_identifier
556
+ * @return boolean
557
+ */
558
+ private static function sem_release( $sem_identifier ) {
559
+ $result = false;
560
+ if ( function_exists( 'sem_release' ) ) {
561
+ $result = @sem_release( $sem_identifier );
562
+ }
563
+ return $result;
564
+ }
565
+
566
+ /**
567
+ * Guarded sem_remove() wrapper.
568
+ *
569
+ * @see sem_remove()
570
+ *
571
+ * @param unknown $sem_identifier
572
+ * @return boolean
573
+ */
574
+ private static function sem_remove( $sem_identifier ) {
575
+ $result = false;
576
+ if ( function_exists( 'sem_remove' ) ) {
577
+ $result = @sem_remove( $sem_identifier );
578
+ }
579
+ return $result;
580
+ }
581
+
582
+ /**
583
+ * Produces a file-based key for use with sem_get().
584
+ *
585
+ * @return number
586
+ */
587
+ private static function get_sem_key() {
588
+ $key = -1;
589
+ if ( function_exists( 'ftok' ) ) {
590
+ $key = ftok( __FILE__, 'g' );
591
+ }
592
+ if ( $key == -1 ) {
593
+ $key = fileinode( __FILE__ );
594
+ }
595
+ return $key;
596
+ }
597
  }
598
  Groups_Controller::boot();
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: itthinx, proaktion
3
  Donate link: http://www.itthinx.com/plugins/groups
4
  Tags: groups, access, access control, membership, memberships, member, members, capability, capabilities, content, download, downloads, file, file access, files, paypal, permission, permissions, subscription, subscriptions, woocommerce
5
  Requires at least: 4.0
6
- Tested up to: 4.7.5
7
- Stable tag: 2.2.0
8
  License: GPLv3
9
 
10
  Groups is an efficient and powerful solution, providing group-based user membership management, group-based capabilities and content access control.
@@ -189,6 +189,19 @@ See also the [Groups Documentation](http://docs.itthinx.com/document/groups/) pa
189
 
190
  == Changelog ==
191
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
  = 2.2.0 =
193
  * Important change in this version: If access restrictions for post type are disabled, related entries will not be protected anymore.
194
  * Improved the activation performance by simplifying the creation of user-group entries.
@@ -263,8 +276,9 @@ See also the [Groups Documentation](http://docs.itthinx.com/document/groups/) pa
263
 
264
  == Upgrade Notice ==
265
 
266
- = 2.2.0 =
267
- Groups 2.x simplifies the way access restrictions are handled.
268
- This release contains performance improvements and fixes.
269
- Important: It also changes the behaviour for post types that Groups should not handle, if a post type is disabled, related entries will not be protected anymore. This is a fundamental change with respect to the previous behavior.
270
- We recommend to make a FULL BACKUP of your site and database before upgrading.
 
3
  Donate link: http://www.itthinx.com/plugins/groups
4
  Tags: groups, access, access control, membership, memberships, member, members, capability, capabilities, content, download, downloads, file, file access, files, paypal, permission, permissions, subscription, subscriptions, woocommerce
5
  Requires at least: 4.0
6
+ Tested up to: 4.8
7
+ Stable tag: 2.3.0
8
  License: GPLv3
9
 
10
  Groups is an efficient and powerful solution, providing group-based user membership management, group-based capabilities and content access control.
189
 
190
  == Changelog ==
191
 
192
+ = 2.3.0 =
193
+ * Tested with WordPress 4.8.
194
+ * Fixed a REST API access restriction issue, added the filter rest_prepare_{$post_type} to
195
+ grant or deny access to individual posts.
196
+ * Updated the translation template.
197
+ * German translation updated.
198
+ * Updated the appearance of the network settings.
199
+ * Updated the table creation process dropping use of dbDelta() due to its restrictions (can't handle IF NOT EXISTS).
200
+ * Fixed an issue related to cache and switching to a blog when neither wp_cache_switch_to_blog() nor wp_cache_reset()
201
+ are implemented, like in WP Engine's object-cache.php which does provide wp_cache_flush().
202
+ * Guarded against concurrent execution of multiple instances of plugin activation and deactivation processes.
203
+ * Fixed an attempt to refresh capabilities when no previous version was installed.
204
+
205
  = 2.2.0 =
206
  * Important change in this version: If access restrictions for post type are disabled, related entries will not be protected anymore.
207
  * Improved the activation performance by simplifying the creation of user-group entries.
276
 
277
  == Upgrade Notice ==
278
 
279
+ = 2.3.0 =
280
+ * This release has been tested with WordPress 4.8, contains a security fix related to the REST API, improvements to stability during activation (undesired concurrent activation, caching, multisite) and updates some translations.
281
+ * Important note for updates below Groups 2.2.0: Groups 2.2.0 and above also changes the behaviour for post types that Groups should not handle, if a post type is disabled, related entries will not be protected anymore.
282
+ This is a fundamental change with respect to the previous behavior.
283
+ * Groups 2.x simplifies the way access restrictions are handled.
284
+ * We recommend to always make a FULL BACKUP of your site and database before upgrading.