├── README.md ├── languages ├── altctrl-public-group-de_DE.mo ├── altctrl-public-group-fr_FR.mo ├── altctrl-public-group-de_DE.po ├── altctrl-public-group.pot └── altctrl-public-group-fr_FR.po ├── css └── altctrl-public-group.css ├── templates └── groups │ ├── single │ ├── front.php │ └── admin │ │ └── group-settings.php │ └── create.php ├── altctrl-public-group.php └── includes ├── settings.php ├── functions.php └── classes └── class-apgc-group-extension.php /README.md: -------------------------------------------------------------------------------- 1 | # Alternative Public Group Control 2 | 3 | This WP/BP Plugin is no more supported and this repository is now archived. 4 | -------------------------------------------------------------------------------- /languages/altctrl-public-group-de_DE.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imath/altctrl-public-group/HEAD/languages/altctrl-public-group-de_DE.mo -------------------------------------------------------------------------------- /languages/altctrl-public-group-fr_FR.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imath/altctrl-public-group/HEAD/languages/altctrl-public-group-fr_FR.mo -------------------------------------------------------------------------------- /css/altctrl-public-group.css: -------------------------------------------------------------------------------- 1 | #buddypress .group-custom-front { 2 | margin:1em 0; 3 | } 4 | 5 | body.group-admin.control #buddypress .standard-form div.wp-editor textarea { 6 | width:100%; 7 | } 8 | 9 | #buddypress #public-group-description { 10 | list-style: none; 11 | margin-left: 0; 12 | } 13 | -------------------------------------------------------------------------------- /templates/groups/single/front.php: -------------------------------------------------------------------------------- 1 | 8 | 9 |
10 | 11 |
12 | -------------------------------------------------------------------------------- /altctrl-public-group.php: -------------------------------------------------------------------------------- 1 | altctrl ) ) { 36 | $bp->altctrl = new self; 37 | } 38 | 39 | return $bp->altctrl; 40 | } 41 | 42 | /** 43 | * Constructor 44 | */ 45 | public function __construct() { 46 | $this->setup_globals(); 47 | $this->includes(); 48 | } 49 | 50 | /** 51 | * Set the includes and templates dirs 52 | */ 53 | private function setup_globals() { 54 | $this->version = '2.0.0'; 55 | $this->domain = 'altctrl-public-group'; 56 | $this->includes_dir = trailingslashit( plugin_dir_path( __FILE__ ) . 'includes' ); 57 | $this->templates_dir = trailingslashit( plugin_dir_path( __FILE__ ) . 'templates' ); 58 | $this->lang_dir = trailingslashit( plugin_dir_path( __FILE__ ) . 'languages' ); 59 | $this->css_url = trailingslashit( plugin_dir_url ( __FILE__ ) . 'css' ); 60 | } 61 | 62 | /** 63 | * Checks BuddyPress version 64 | * 65 | * @since 1.1.0 66 | */ 67 | public function bp_version_check() { 68 | // taking no risk 69 | if ( ! defined( 'BP_VERSION' ) ) { 70 | return false; 71 | } 72 | 73 | return version_compare( BP_VERSION, '2.6.0', '>=' ); 74 | } 75 | 76 | /** 77 | * Include the needed file 78 | * 79 | * @since 1.0.0 80 | */ 81 | private function includes() { 82 | if ( ! bp_is_active( 'groups' ) || ! $this->bp_version_check() ) { 83 | return; 84 | } 85 | 86 | spl_autoload_register( array( $this, 'autoload' ) ); 87 | 88 | require $this->includes_dir . 'functions.php'; 89 | 90 | if ( is_admin() ) { 91 | require $this->includes_dir . 'settings.php'; 92 | } 93 | } 94 | 95 | /** 96 | * Class Autoload function 97 | * 98 | * @since 2.0.0 99 | * 100 | * @param string $class The class name. 101 | */ 102 | public function autoload( $class ) { 103 | $name = str_replace( '_', '-', strtolower( $class ) ); 104 | 105 | if ( 0 !== strpos( $name, 'apgc' ) ) { 106 | return; 107 | } 108 | 109 | $path = $this->includes_dir . "classes/class-{$name}.php"; 110 | 111 | // Sanity check. 112 | if ( ! file_exists( $path ) ) { 113 | return; 114 | } 115 | 116 | require $path; 117 | } 118 | } 119 | add_action( 'bp_include', array( 'Alt_Public_Group_Ctrl_Loader', 'start' ) ); 120 | -------------------------------------------------------------------------------- /languages/altctrl-public-group-de_DE.po: -------------------------------------------------------------------------------- 1 | msgid "" 2 | msgstr "" 3 | "Project-Id-Version: Alternative Public Group Control\n" 4 | "POT-Creation-Date: 2015-01-31 13:02+0100\n" 5 | "PO-Revision-Date: 2015-01-31 13:13+0100\n" 6 | "Last-Translator: Simon Kraft (krafit.de) \n" 7 | "Language-Team: Simon Kraft (trns.nl) \n" 8 | "Language: de\n" 9 | "MIME-Version: 1.0\n" 10 | "Content-Type: text/plain; charset=UTF-8\n" 11 | "Content-Transfer-Encoding: 8bit\n" 12 | "X-Generator: Poedit 1.7.1\n" 13 | "X-Poedit-Basepath: ..\n" 14 | "X-Poedit-SourceCharset: UTF-8\n" 15 | "X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;" 16 | "esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;" 17 | "_nx_noop:3c,1,2;__ngettext_noop:1,2\n" 18 | "Plural-Forms: nplurals=2; plural=(n != 1);\n" 19 | "X-Poedit-SearchPath-0: .\n" 20 | 21 | #: includes/alt-public-group-ctrl.php:23 22 | msgid "Control" 23 | msgstr "Mitgliedschafts-Kontrolle" 24 | 25 | #: includes/alt-public-group-ctrl.php:75 26 | msgctxt "post type general name" 27 | msgid "Groups front" 28 | msgstr "Gruppen-Startseite" 29 | 30 | #: includes/alt-public-group-ctrl.php:76 31 | msgctxt "post type singular name" 32 | msgid "Group front" 33 | msgstr "Gruppen-Startseite" 34 | 35 | #: includes/alt-public-group-ctrl.php:136 36 | msgid "This area is restricted to group members" 37 | msgstr "Dieser Bereich ist nur für Gruppenmitgliedern zugänglich" 38 | 39 | #: includes/alt-public-group-ctrl.php:145 40 | #: includes/alt-public-group-ctrl.php:305 41 | #: includes/alt-public-group-ctrl.php:306 42 | msgid "Request Membership" 43 | msgstr "Mitgliedschaft anfragen" 44 | 45 | #: includes/alt-public-group-ctrl.php:177 46 | msgid "Requests" 47 | msgstr "Anfragen" 48 | 49 | #: includes/alt-public-group-ctrl.php:191 50 | msgid "" 51 | "Your membership request was sent to the group administrator successfully. " 52 | "You will be notified when the group administrator responds to your request." 53 | msgstr "" 54 | "Deine Mitgliedschafts-Anfrage wurde registriert. Du wird benachrichtigt, " 55 | "sobald ein Gruppen-Administrator auf deine Anfrage reagiert." 56 | 57 | #: includes/alt-public-group-ctrl.php:279 58 | #: includes/alt-public-group-ctrl.php:280 59 | msgid "Accept Invitation" 60 | msgstr "Einladung annehmen" 61 | 62 | #: includes/alt-public-group-ctrl.php:292 63 | #: includes/alt-public-group-ctrl.php:293 64 | msgid "Request Sent" 65 | msgstr "Anfrage gesendet" 66 | 67 | #: includes/alt-public-group-ctrl.php:453 68 | msgid "Joining group" 69 | msgstr "Gruppenbeitritt" 70 | 71 | #: includes/alt-public-group-ctrl.php:456 72 | msgid "Users need to submit a request to join group" 73 | msgstr "Benutzer müssen den Beitritt zu dieser Gruppe beantragen" 74 | 75 | #: includes/alt-public-group-ctrl.php:463 76 | msgid "Group members only tabs" 77 | msgstr "Zugang limitieren" 78 | 79 | #: includes/alt-public-group-ctrl.php:479 80 | msgid "Use the checkboxes to choose the tabs to hide to non members" 81 | msgstr "Welche Tabs sollen nur für Mitglieder zugänglich sein?" 82 | 83 | #: includes/alt-public-group-ctrl.php:485 84 | msgid "Group's home page" 85 | msgstr "Gruppen-Startseite" 86 | 87 | #: includes/alt-public-group-ctrl.php:488 88 | msgid "Use a custom front page for non group members" 89 | msgstr "Zeige nicht angemeldeten Nutzern eine andere Gruppen-Startseite." 90 | 91 | #: includes/alt-public-group-ctrl.php:512 92 | msgid "Save" 93 | msgstr "Speichern" 94 | 95 | #: includes/alt-public-group-ctrl.php:573 96 | msgid "Settings saved successfully" 97 | msgstr "Einstellungen erfolgreich gespeichert" 98 | -------------------------------------------------------------------------------- /includes/settings.php: -------------------------------------------------------------------------------- 1 | 53 | 54 |
55 | 56 |
    57 | 58 | $visibility ) : 59 | 60 | $readonly = ''; 61 | if ( in_array( $key, array( 'public-open', 'public-request' ), true ) ) { 62 | $readonly = ' readonly="readonly"'; 63 | } 64 | 65 | $disabled = ''; 66 | if ( $is_restriced || ( $key === 'public-invite' && ! bp_is_active( 'friends' ) ) ) { 67 | $disabled = ' disabled="disabled"'; 68 | } 69 | ?> 70 |
  • 71 | 74 |
  • 75 | 76 |
77 |
78 | 79 |

80 | 81 | 106 | /> 107 | 108 | 8 | 9 |

10 | 11 | 19 | 20 |
21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 |
    29 | 30 |
31 | 32 |
33 | 34 |
35 | 36 | 37 | true ), 'objects' ) ): ?> 38 | 39 |
40 | 41 | 42 |

43 | 44 | 45 |
46 | 54 |
55 | 56 | 57 | 58 |
59 | 60 | 61 | 62 | 67 | 68 |
69 | 70 | 71 | 72 |

73 | 74 |
75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 |
83 | 84 |
85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 100 | 101 |

102 | \n" 13 | "Language-Team: LANGUAGE \n" 14 | 15 | #: includes/classes/class-apgc-group-extension.php:43 16 | msgid "Control" 17 | msgstr "" 18 | 19 | #: includes/classes/class-apgc-group-extension.php:97 20 | msgctxt "post type general name" 21 | msgid "Groups front" 22 | msgstr "" 23 | 24 | #: includes/classes/class-apgc-group-extension.php:98 25 | msgctxt "post type singular name" 26 | msgid "Group front" 27 | msgstr "" 28 | 29 | #: includes/classes/class-apgc-group-extension.php:140 30 | msgid "Requests" 31 | msgstr "" 32 | 33 | #: includes/classes/class-apgc-group-extension.php:171 34 | msgid "This area is restricted to group members" 35 | msgstr "" 36 | 37 | #: includes/classes/class-apgc-group-extension.php:180 38 | #: includes/classes/class-apgc-group-extension.php:346 39 | #: includes/classes/class-apgc-group-extension.php:347 40 | msgid "Request Membership" 41 | msgstr "" 42 | 43 | #: includes/classes/class-apgc-group-extension.php:218 44 | msgid "Your membership request was sent to the group administrator successfully. You will be notified when the group administrator responds to your request." 45 | msgstr "" 46 | 47 | #: includes/classes/class-apgc-group-extension.php:318 48 | #: includes/classes/class-apgc-group-extension.php:319 49 | msgid "Accept Invitation" 50 | msgstr "" 51 | 52 | #: includes/classes/class-apgc-group-extension.php:331 53 | #: includes/classes/class-apgc-group-extension.php:332 54 | msgid "Request Sent" 55 | msgstr "" 56 | 57 | #: includes/classes/class-apgc-group-extension.php:547 58 | #: includes/classes/class-apgc-group-extension.php:716 59 | msgid "Joining group" 60 | msgstr "" 61 | 62 | #: includes/classes/class-apgc-group-extension.php:555 63 | msgid "Group members only tabs" 64 | msgstr "" 65 | 66 | #: includes/classes/class-apgc-group-extension.php:572 67 | msgid "Use the checkboxes to choose the tabs to hide to non members" 68 | msgstr "" 69 | 70 | #: includes/classes/class-apgc-group-extension.php:578 71 | msgid "Group's home page" 72 | msgstr "" 73 | 74 | #: includes/classes/class-apgc-group-extension.php:581 75 | msgid "Use a custom front page for non group members" 76 | msgstr "" 77 | 78 | #: includes/classes/class-apgc-group-extension.php:605 79 | msgid "Save" 80 | msgstr "" 81 | 82 | #: includes/classes/class-apgc-group-extension.php:668 83 | msgid "Settings saved successfully" 84 | msgstr "" 85 | 86 | #: includes/classes/class-apgc-group-extension.php:713 87 | msgid "The control features are only available for public groups" 88 | msgstr "" 89 | 90 | #: includes/functions.php:57 91 | msgid "Public" 92 | msgstr "" 93 | 94 | #: includes/functions.php:58 95 | msgid "Any site member can join this group." 96 | msgstr "" 97 | 98 | #: includes/functions.php:63 99 | msgid "Public with membership requests" 100 | msgstr "" 101 | 102 | #: includes/functions.php:64 103 | msgid "The site member needs to request a group membership." 104 | msgstr "" 105 | 106 | #: includes/functions.php:69 107 | msgid "Public for invited members only" 108 | msgstr "" 109 | 110 | #: includes/functions.php:70 111 | msgid "The site member needs to be invited to join the group." 112 | msgstr "" 113 | 114 | #: includes/functions.php:75 115 | msgid "Private or Hidden" 116 | msgstr "" 117 | 118 | #: includes/functions.php:294 119 | msgid "There was an error saving the group privacy option. Please try again." 120 | msgstr "" 121 | 122 | #: includes/settings.php:21 123 | msgid "Available Group visibilities" 124 | msgstr "" 125 | 126 | #: includes/settings.php:31 127 | msgid "Public Groups Manage Control Screen" 128 | msgstr "" 129 | 130 | #: includes/settings.php:53 131 | msgid "Visibility levels" 132 | msgstr "" 133 | 134 | #: includes/settings.php:77 135 | msgid "Activate the checkboxes regular members can use." 136 | msgstr "" 137 | 138 | #: includes/settings.php:105 139 | msgid "Disable" 140 | msgstr "" 141 | 142 | #. translators: accessibility text 143 | 144 | #: templates/groups/create.php:56 145 | msgid "Group Settings" 146 | msgstr "" 147 | 148 | #: templates/groups/create.php:70 149 | #: templates/groups/single/admin/group-settings.php:22 150 | msgid "Privacy Options" 151 | msgstr "" 152 | 153 | #: templates/groups/create.php:88 154 | #: templates/groups/single/admin/group-settings.php:40 155 | msgid "Group Types" 156 | msgstr "" 157 | 158 | #: templates/groups/create.php:90 159 | #: templates/groups/single/admin/group-settings.php:42 160 | msgid "Select the types this group should be a part of." 161 | msgstr "" 162 | 163 | #. translators: Group type description shown when creating a group. 164 | 165 | #: templates/groups/create.php:98 166 | #: templates/groups/single/admin/group-settings.php:50 167 | msgid "– %s" 168 | msgstr "" 169 | 170 | #: templates/groups/create.php:118 171 | #: templates/groups/single/admin/group-settings.php:70 172 | msgid "Group Invitations" 173 | msgstr "" 174 | 175 | #: templates/groups/create.php:120 176 | #: templates/groups/single/admin/group-settings.php:72 177 | msgid "Which members of this group are allowed to invite others?" 178 | msgstr "" 179 | 180 | #: templates/groups/create.php:124 181 | #: templates/groups/single/admin/group-settings.php:76 182 | msgid "All group members" 183 | msgstr "" 184 | 185 | #: templates/groups/create.php:126 186 | #: templates/groups/single/admin/group-settings.php:78 187 | msgid "Group admins and mods only" 188 | msgstr "" 189 | 190 | #: templates/groups/create.php:128 191 | #: templates/groups/single/admin/group-settings.php:80 192 | msgid "Group admins only" 193 | msgstr "" 194 | 195 | #: templates/groups/create.php:142 196 | msgid "Group Forums" 197 | msgstr "" 198 | 199 | #: templates/groups/create.php:144 200 | msgid "Attention Site Admin: the legacy Group forums are retired and not supported by the Alternative Public Group Control plugin." 201 | msgstr "" 202 | 203 | #: templates/groups/create.php:170 204 | msgid "Back to Previous Step" 205 | msgstr "" 206 | 207 | #: templates/groups/create.php:171 208 | msgid "Next Step" 209 | msgstr "" 210 | 211 | #: templates/groups/single/admin/group-settings.php:9 212 | msgid "Manage Group Settings" 213 | msgstr "" 214 | 215 | #: templates/groups/single/admin/group-settings.php:101 216 | msgid "Save Changes" 217 | msgstr "" 218 | #. Plugin Name of the plugin/theme 219 | msgid "Alternative Public Group Control" 220 | msgstr "" 221 | 222 | #. Plugin URI of the plugin/theme 223 | msgid "https://imathi.eu/2014/06/15/altctrl-public-group/" 224 | msgstr "" 225 | 226 | #. Description of the plugin/theme 227 | msgid "Adds visibility levels to BuddyPress public groups." 228 | msgstr "" 229 | 230 | #. Author of the plugin/theme 231 | msgid "imath" 232 | msgstr "" 233 | 234 | #. Author URI of the plugin/theme 235 | msgid "https://imathi.eu" 236 | msgstr "" 237 | -------------------------------------------------------------------------------- /templates/groups/create.php: -------------------------------------------------------------------------------- 1 | 14 | 15 |
16 | 17 | 25 | 26 |
27 | 28 | 36 | 37 |
38 |
    39 | 40 | 41 | 42 |
43 |
44 | 45 | 52 | 53 |
54 |

58 | 59 | 67 | 68 |
69 | 70 | 71 | 72 |
73 | 74 | 75 | 76 |
    77 | 78 |
79 | 80 |
81 | 82 |
83 | 84 | 85 | true ), 'objects' ) ): ?> 86 | 87 |
88 | 89 | 90 |

91 | 92 | 93 |
94 | 102 |
103 | 104 | 105 | 106 |
107 | 108 | 109 | 110 | 115 | 116 |
117 | 118 | 119 | 120 |

121 | 122 |
123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 |
131 | 132 |
133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 |

143 | 144 |

145 | 146 | 147 | 148 | 156 | 157 | 158 | 159 | 167 | 168 |
169 | 170 | 171 | 172 | 173 |
174 | 175 | 183 | 184 | 185 | 186 | 187 | 195 | 196 |
197 | 198 | 206 | 207 |
208 | 209 | 217 | 218 |
219 | 220 | \n" 10 | "Language-Team: Français \n" 11 | "Language: fr_FR\n" 12 | "MIME-Version: 1.0\n" 13 | "Content-Type: text/plain; charset=UTF-8\n" 14 | "Content-Transfer-Encoding: 8bit\n" 15 | "X-Generator: Poedit 1.7.1\n" 16 | "Plural-Forms: nplurals=2; plural=(n > 1);\n" 17 | 18 | #: includes/classes/class-apgc-group-extension.php:43 19 | msgid "Control" 20 | msgstr "Contrôle" 21 | 22 | #: includes/classes/class-apgc-group-extension.php:97 23 | msgctxt "post type general name" 24 | msgid "Groups front" 25 | msgstr "Page de groupes" 26 | 27 | #: includes/classes/class-apgc-group-extension.php:98 28 | msgctxt "post type singular name" 29 | msgid "Group front" 30 | msgstr "Page de groupe" 31 | 32 | #: includes/classes/class-apgc-group-extension.php:140 33 | msgid "Requests" 34 | msgstr "Demande d'adhésion" 35 | 36 | #: includes/classes/class-apgc-group-extension.php:171 37 | msgid "This area is restricted to group members" 38 | msgstr "Cette zone est réservée aux membres du groupe." 39 | 40 | #: includes/classes/class-apgc-group-extension.php:180 41 | #: includes/classes/class-apgc-group-extension.php:346 42 | #: includes/classes/class-apgc-group-extension.php:347 43 | msgid "Request Membership" 44 | msgstr "Adhérer" 45 | 46 | #: includes/classes/class-apgc-group-extension.php:218 47 | msgid "" 48 | "Your membership request was sent to the group administrator successfully. You will be notified " 49 | "when the group administrator responds to your request." 50 | msgstr "" 51 | "Votre demande d'adhésion a été transmise à l'administrateur du groupe. Vous serez " 52 | "notifié lorsque il y aura répondu." 53 | 54 | #: includes/classes/class-apgc-group-extension.php:318 55 | #: includes/classes/class-apgc-group-extension.php:319 56 | msgid "Accept Invitation" 57 | msgstr "Accepter l'invitation" 58 | 59 | #: includes/classes/class-apgc-group-extension.php:331 60 | #: includes/classes/class-apgc-group-extension.php:332 61 | msgid "Request Sent" 62 | msgstr "Demande transmise" 63 | 64 | #: includes/classes/class-apgc-group-extension.php:547 65 | #: includes/classes/class-apgc-group-extension.php:716 66 | msgid "Joining group" 67 | msgstr "Devenir membre du groupe" 68 | 69 | #: includes/classes/class-apgc-group-extension.php:555 70 | msgid "Group members only tabs" 71 | msgstr "Onglets réservés aux membres du groupe" 72 | 73 | #: includes/classes/class-apgc-group-extension.php:572 74 | msgid "Use the checkboxes to choose the tabs to hide to non members" 75 | msgstr "Utilisez les case à cocher pour cacher les onglets aux non membres." 76 | 77 | #: includes/classes/class-apgc-group-extension.php:578 78 | msgid "Group's home page" 79 | msgstr "Page d'accueil du groupe" 80 | 81 | #: includes/classes/class-apgc-group-extension.php:581 82 | msgid "Use a custom front page for non group members" 83 | msgstr "Utiliser une page d'accueil spécifique pour les non membres du groupe" 84 | 85 | #: includes/classes/class-apgc-group-extension.php:605 86 | msgid "Save" 87 | msgstr "Sauvegarder" 88 | 89 | #: includes/classes/class-apgc-group-extension.php:668 90 | msgid "Settings saved successfully" 91 | msgstr "Réglages sauvegardés." 92 | 93 | #: includes/classes/class-apgc-group-extension.php:713 94 | msgid "The control features are only available for public groups" 95 | msgstr "Les fonctionnalités de contrôle sont uniquement disponibles pour les groupes publics." 96 | 97 | #: includes/functions.php:57 98 | msgid "Public" 99 | msgstr "Public" 100 | 101 | #: includes/functions.php:58 102 | msgid "Any site member can join this group." 103 | msgstr "Tous les membres du site peuvent adhérer à ce groupe." 104 | 105 | #: includes/functions.php:63 106 | msgid "Public with membership requests" 107 | msgstr "Public avec demande d'adhésion" 108 | 109 | #: includes/functions.php:64 110 | msgid "The site member needs to request a group membership." 111 | msgstr "Les membres du site doivent demander à adhérer au groupe." 112 | 113 | #: includes/functions.php:69 114 | msgid "Public for invited members only" 115 | msgstr "Public sur invitation seulement" 116 | 117 | #: includes/functions.php:70 118 | msgid "The site member needs to be invited to join the group." 119 | msgstr "Les membres du site doivent être invités à rejoindre ce groupe." 120 | 121 | #: includes/functions.php:75 122 | msgid "Private or Hidden" 123 | msgstr "Privé ou Masqué" 124 | 125 | #: includes/functions.php:294 126 | msgid "There was an error saving the group privacy option. Please try again." 127 | msgstr "" 128 | "Une erreur est survenue pendant l'enregistrement de la visibilité du groupe. Veuillez " 129 | "recommencer." 130 | 131 | #: includes/settings.php:21 132 | msgid "Available Group visibilities" 133 | msgstr "Visibilités de groupe disponibles" 134 | 135 | #: includes/settings.php:31 136 | msgid "Public Groups Manage Control Screen" 137 | msgstr "Page de contrôle du groupe" 138 | 139 | #: includes/settings.php:53 140 | msgid "Visibility levels" 141 | msgstr "Niveaux de visibilité" 142 | 143 | #: includes/settings.php:77 144 | msgid "Activate the checkboxes regular members can use." 145 | msgstr "Activez les cases à cocher pour les options que les membres peuvent utiliser." 146 | 147 | #: includes/settings.php:105 148 | msgid "Disable" 149 | msgstr "Désactiver" 150 | 151 | #. translators: accessibility text 152 | #: templates/groups/create.php:56 153 | msgid "Group Settings" 154 | msgstr "Réglages de groupe" 155 | 156 | #: templates/groups/create.php:70 templates/groups/single/admin/group-settings.php:22 157 | msgid "Privacy Options" 158 | msgstr "Options de visibilité" 159 | 160 | #: templates/groups/create.php:88 templates/groups/single/admin/group-settings.php:40 161 | msgid "Group Types" 162 | msgstr "Types de groupe" 163 | 164 | #: templates/groups/create.php:90 templates/groups/single/admin/group-settings.php:42 165 | msgid "Select the types this group should be a part of." 166 | msgstr "Sélectionnez les types auxquels ce groupe peut appartenir." 167 | 168 | #. translators: Group type description shown when creating a group. 169 | #: templates/groups/create.php:98 templates/groups/single/admin/group-settings.php:50 170 | msgid "– %s" 171 | msgstr "– %s" 172 | 173 | #: templates/groups/create.php:118 templates/groups/single/admin/group-settings.php:70 174 | msgid "Group Invitations" 175 | msgstr "Invitations à rejoindre le groupe" 176 | 177 | #: templates/groups/create.php:120 templates/groups/single/admin/group-settings.php:72 178 | msgid "Which members of this group are allowed to invite others?" 179 | msgstr "Quels membres de ce groupe sont autorisés à inviter d'autres membres à les rejoindre ?" 180 | 181 | #: templates/groups/create.php:124 templates/groups/single/admin/group-settings.php:76 182 | msgid "All group members" 183 | msgstr "Tous les membres du groupe" 184 | 185 | #: templates/groups/create.php:126 templates/groups/single/admin/group-settings.php:78 186 | msgid "Group admins and mods only" 187 | msgstr "Uniquement les aministrateurs de groupe et les modérateurs" 188 | 189 | #: templates/groups/create.php:128 templates/groups/single/admin/group-settings.php:80 190 | msgid "Group admins only" 191 | msgstr "Uniquement les admins du groupe" 192 | 193 | #: templates/groups/create.php:142 194 | msgid "Group Forums" 195 | msgstr "Forums de groupe" 196 | 197 | #: templates/groups/create.php:144 198 | msgid "" 199 | "Attention Site Admin: the legacy Group forums are retired and not supported by the Alternative " 200 | "Public Group Control plugin." 201 | msgstr "" 202 | "Attention Site Admin : les anciens forums de groupe sont à la retraite et ne sont pas pris en " 203 | "charge par l'extension de contrôle alternatif des groupes publics." 204 | 205 | #: templates/groups/create.php:170 206 | msgid "Back to Previous Step" 207 | msgstr "Revenir à l'étape précédente" 208 | 209 | #: templates/groups/create.php:171 210 | msgid "Next Step" 211 | msgstr "Étape suivante" 212 | 213 | #: templates/groups/single/admin/group-settings.php:9 214 | msgid "Manage Group Settings" 215 | msgstr "Gestion du groupe" 216 | 217 | #: templates/groups/single/admin/group-settings.php:101 218 | msgid "Save Changes" 219 | msgstr "Enregistrer les modifications" 220 | 221 | #. Plugin Name of the plugin/theme 222 | msgid "Alternative Public Group Control" 223 | msgstr "Contrôle alternatif pour les groupes publics" 224 | 225 | #. Plugin URI of the plugin/theme 226 | msgid "https://imathi.eu/2014/06/15/altctrl-public-group/" 227 | msgstr "https://imathi.eu/2014/06/15/altctrl-public-group/" 228 | 229 | #. Description of the plugin/theme 230 | msgid "Adds visibility levels to BuddyPress public groups." 231 | msgstr "Ajoute des niveaux de visibilité à des groupes publics BuddyPress." 232 | 233 | #. Author of the plugin/theme 234 | msgid "imath" 235 | msgstr "imath" 236 | 237 | #. Author URI of the plugin/theme 238 | msgid "https://imathi.eu" 239 | msgstr "https://imathi.eu" 240 | -------------------------------------------------------------------------------- /includes/functions.php: -------------------------------------------------------------------------------- 1 | altctrl; 24 | } 25 | 26 | /** 27 | * Registers the Group Extension. 28 | * 29 | * @since 2.0.0 30 | */ 31 | function apgc_register_group_extension() { 32 | bp_register_group_extension( 'APGC_Group_Extension' ); 33 | } 34 | add_action( 'bp_init', 'apgc_register_group_extension' ); 35 | 36 | /** 37 | * Get the "any user" allowed Group visibilities. 38 | * 39 | * @since 2.0.0 40 | * 41 | * @param array $default The default "any user" allowed Group visibilities. 42 | * @return array The "any user" allowed Group visibilities. 43 | */ 44 | function apgc_get_allowed_visibility_levels( $default = array( 'public-open', 'public-request' ) ) { 45 | return (array) bp_get_option( '_apgc_restrict_group_visibility', $default ); 46 | } 47 | 48 | /** 49 | * Get the supported Group visibilities. 50 | * 51 | * @since 2.0.0 52 | * 53 | * @return array The supported Group visibilities. 54 | */ 55 | function apgc_get_visibility_levels() { 56 | return array( 57 | 'public-open' => array( 58 | 'id' => 'public-open', 59 | 'title' => __( 'Public', 'altctrl-public-group' ), 60 | 'description' => __( 'Any site member can join this group.', 'altctrl-public-group' ), 61 | 'public' => true, 62 | ), 63 | 'public-request' => array( 64 | 'id' => 'public-request', 65 | 'title' => __( 'Public with membership requests', 'altctrl-public-group' ), 66 | 'description' => __( 'The site member needs to request a group membership.', 'altctrl-public-group' ), 67 | 'public' => true, 68 | ), 69 | 'public-invite' => array( 70 | 'id' => 'public-invite', 71 | 'title' => __( 'Public for invited members only', 'altctrl-public-group' ), 72 | 'description' => __( 'The site member needs to be invited to join the group.', 'altctrl-public-group' ), 73 | 'public' => true, 74 | ), 75 | 'private-hidden' => array( 76 | 'id' => 'private-hidden', 77 | 'title' => __( 'Private or Hidden', 'altctrl-public-group' ), 78 | 'description' => '', 79 | 'public' => false, 80 | ), 81 | ); 82 | } 83 | 84 | /** 85 | * Load translations. 86 | * 87 | * @since 2.0.0 88 | */ 89 | function apgc_load_textdomain() { 90 | // Get plugin's intance. 91 | $apgc = apgc_instance(); 92 | 93 | // Traditional WordPress plugin locale filter 94 | $locale = apply_filters( 'plugin_locale', get_locale(), $apgc->domain ); 95 | $mofile = sprintf( '%1$s-%2$s.mo', $apgc->domain, $locale ); 96 | 97 | // Setup paths to current locale file 98 | $mofile_local = $apgc->lang_dir . $mofile; 99 | $mofile_global = WP_LANG_DIR . '/altctrl-public-group/' . $mofile; 100 | 101 | // Look in global /wp-content/languages/altctrl-public-group folder 102 | load_textdomain( $apgc->domain, $mofile_global ); 103 | 104 | // Look in local /wp-content/plugins/altctrl-public-group/languages/ folder 105 | load_textdomain( $apgc->domain, $mofile_local ); 106 | 107 | // Look in global /wp-content/languages/plugins/ 108 | load_plugin_textdomain( $apgc->domain ); 109 | } 110 | add_action( 'bp_init', 'apgc_load_textdomain', 5 ); 111 | 112 | function apgc_can_current_user_do_private_groups() { 113 | return in_array( 'private-hidden', apgc_get_allowed_visibility_levels(), true ) || bp_current_user_can( 'bp_moderate' ); 114 | } 115 | 116 | /** 117 | * Should the plugin override BuddyPress build-in templates ? 118 | * 119 | * @since 2.0.0 120 | * 121 | * @return boolean True if it should. False otherwise. 122 | */ 123 | function apgc_override_template_stack() { 124 | $return = APGC_Group_Extension::show_front_page(); 125 | 126 | if ( ! $return && ! apgc_can_current_user_do_private_groups() ) { 127 | if ( bp_is_group_create() ) { 128 | $return = bp_is_group_creation_step( 'group-settings' ); 129 | } else { 130 | $return = bp_is_group_admin_screen( 'group-settings' ); 131 | } 132 | } 133 | 134 | return $return; 135 | } 136 | 137 | /** 138 | * Inject Plugin's templates dir into the BuddyPress Templates dir stack. 139 | * 140 | * @since 2.0.0 141 | * 142 | * @param array $template_stack The list of available locations to get BuddyPress templates 143 | * @return array The list of available locations to get BuddyPress templates 144 | */ 145 | function apgc_template_stack( $template_stack = array() ) { 146 | if ( apgc_override_template_stack() ) { 147 | /** 148 | * Filter here returning false, to not override theme templates. 149 | * 150 | * @since 2.0.0 151 | * 152 | * @param boolean $value True to override all templates. 153 | * False to only override BP Template Pack. 154 | */ 155 | if ( true === apply_filters( 'apgc_template_stack_override_theme', true ) ) { 156 | return array_merge( 157 | array( buddypress()->altctrl->templates_dir ), 158 | $template_stack 159 | ); 160 | } 161 | 162 | $priority = 0; 163 | 164 | foreach ( $template_stack as $itpl => $template ) { 165 | if ( false !== strrpos( $template, bp_get_theme_compat_dir() ) ) { 166 | $priority = $itpl; 167 | break; 168 | } 169 | } 170 | 171 | // Before BuddyPress active's template pack or first if no template packs are in use. 172 | $bp_legacy = array_splice( $template_stack, $itpl ); 173 | 174 | $template_stack = array_merge( 175 | $template_stack, 176 | array( buddypress()->altctrl->templates_dir ), 177 | $bp_legacy 178 | ); 179 | } 180 | 181 | return $template_stack; 182 | } 183 | add_filter( 'bp_get_template_stack', 'apgc_template_stack', 10, 1 ); 184 | 185 | /** 186 | * Outputs the public visibiity options. 187 | * 188 | * @since 2.0.0 189 | * 190 | * @param integer $group_id The Group ID. 191 | */ 192 | function apgc_group_visibility_options( $group_id = 0 ) { 193 | if ( ! $group_id ) { 194 | $group_id = bp_get_current_group_id(); 195 | } 196 | 197 | if ( ! $group_id ) { 198 | $group_id = bp_get_new_group_id(); 199 | } 200 | 201 | $visibilities = wp_filter_object_list( apgc_get_visibility_levels(), array( 'public' => true ) ); 202 | $allowed = apgc_get_allowed_visibility_levels(); 203 | $current = apgc_group_get_visibility_level( $group_id ); 204 | 205 | $output = array(); 206 | foreach ( $visibilities as $visibility ) { 207 | if ( ! in_array( $visibility['id'], $allowed, true ) || ( 'public-invite' === $visibility['id'] && ! bp_is_active( 'friends' ) ) ) { 208 | continue; 209 | } 210 | 211 | $checked = ' ' . checked( $current, $visibility['id'], false ); 212 | $output[] = sprintf( 213 | ' 217 |

%4$s

', 218 | esc_attr( $visibility['id'] ), 219 | $checked, 220 | esc_html( $visibility['title'] ), 221 | esc_html( $visibility['description'] ) 222 | ); 223 | } 224 | 225 | echo '
  • ' . join( '
  • ', $output ) . '
  • '; 226 | } 227 | 228 | /** 229 | * Get the public visibility level of a Public Group. 230 | * 231 | * @since 2.0.0 232 | * 233 | * @param integer $group_id The group ID. 234 | * @return string The Public group's visibility. 235 | */ 236 | function apgc_group_get_visibility_level( $group_id = 0 ) { 237 | if ( ! bp_is_active( 'groups' ) ) { 238 | return false; 239 | } 240 | 241 | $visibility = groups_get_groupmeta( $group_id, '_altctrl_visibility_level', true ); 242 | if ( ! $visibility ) { 243 | $visibility = 'public-open'; 244 | } 245 | 246 | return $visibility; 247 | } 248 | 249 | /** 250 | * Saves the Public group's visibility. 251 | * 252 | * @since 2.0.0 253 | * 254 | * @param integer $group_id The group ID. 255 | * @param string $visibility The Public group's visibility. 256 | * @return boolean True on success. False otherwise. 257 | */ 258 | function apgc_group_update_visibility_level( $group_id = 0, $visibility = 'public-open' ) { 259 | if ( ! bp_is_active( 'groups' ) || ! $group_id ) { 260 | return false; 261 | } 262 | 263 | if ( ! empty( $visibility ) ) { 264 | $visibilities = wp_filter_object_list( apgc_get_visibility_levels(), array( 'public' => true ), 'and', 'id' ); 265 | $allowed = apgc_get_allowed_visibility_levels(); 266 | 267 | if ( ! isset( $visibilities[ $visibility ] ) || ! in_array( $visibility, $allowed, true ) ) { 268 | return false; 269 | } 270 | 271 | groups_update_groupmeta( $group_id, '_altctrl_visibility_level', sanitize_key( $visibility ) ); 272 | } else { 273 | groups_delete_groupmeta( $group_id, '_altctrl_visibility_level' ); 274 | } 275 | 276 | return true; 277 | } 278 | 279 | /** 280 | * Creates/Edits the Public group's visibility setting. 281 | * 282 | * @since 2.0.0 283 | */ 284 | function apgc_group_create_group_visibility_setting() { 285 | if ( ! isset( $_POST['_altctrl_visibility_level'] ) ) { 286 | return; 287 | } 288 | 289 | $group_id = bp_get_current_group_id(); 290 | 291 | if ( ! $group_id ) { 292 | $group_id = bp_get_new_group_id(); 293 | } 294 | 295 | if ( ! apgc_group_update_visibility_level( $group_id, $_POST['_altctrl_visibility_level'] ) ) { 296 | bp_core_add_message( __( 'There was an error saving the group privacy option. Please try again.', 'altctrl-public-group' ), 'error' ); 297 | 298 | if ( bp_is_group_create() ) { 299 | $redirect = bp_core_redirect( trailingslashit( bp_get_groups_directory_permalink() . 'create/step/' . bp_get_groups_current_create_step() ) ); 300 | } 301 | } 302 | } 303 | add_action( 'groups_create_group_step_save_group-settings', 'apgc_group_create_group_visibility_setting' ); 304 | add_action( 'groups_group_settings_edited', 'apgc_group_create_group_visibility_setting' ); 305 | 306 | /** 307 | * Is the Manage Control screen disabled for Public Groups? 308 | * 309 | * @since 2.0.0 310 | * 311 | * @return boolean True if the Control screen is disabled. False otherwise. 312 | */ 313 | function apgc_disable_group_control_screen() { 314 | return (bool) bp_get_option( '_apgc_disable_group_control', false ); 315 | } 316 | -------------------------------------------------------------------------------- /includes/classes/class-apgc-group-extension.php: -------------------------------------------------------------------------------- 1 | is_public_group(); 32 | $admin_screen = array(); 33 | 34 | if ( $is_public_group ) { 35 | $admin_screen = array( 36 | 'metabox_context' => 'side', 37 | 'metabox_priority' => 'high', 38 | ); 39 | } 40 | 41 | parent::init( array( 42 | 'slug' => 'control', 43 | 'name' => __( 'Control', 'altctrl-public-group' ), 44 | 'visibility' => 'private', 45 | 'nav_item_position' => 91, 46 | 'enable_nav_item' => false, 47 | 'screens' => array( 48 | 'admin' => array_merge( array( 49 | 'enabled' => $is_public_group, 50 | ), $admin_screen ), 51 | 'create' => array( 52 | 'enabled' => false, 53 | ), 54 | 'edit' => array( 55 | 'enabled' => $is_public_group && ( ! apgc_disable_group_control_screen() || bp_current_user_can( 'bp_moderate' ) ), 56 | ), 57 | ), 58 | ) ); 59 | 60 | $this->setup_hooks(); 61 | $this->register_post_type(); 62 | } 63 | 64 | /** 65 | * Set some hooks (Actions & filters) 66 | * 67 | * @since 1.0.0 68 | */ 69 | private function setup_hooks() { 70 | // Actions 71 | add_action( 'bp_actions', array( $this, 'control' ) ); 72 | add_action( 'groups_screen_group_request_membership', array( $this, 'maybe_restore_status' ) ); 73 | add_action( 'groups_screen_group_admin_requests', array( $this, 'maybe_restore_status' ) ); 74 | add_action( 'bp_after_group_request_membership_content', array( $this, 'maybe_request_info' ) ); 75 | add_action( 'bp_enqueue_scripts', array( $this, 'enqueue_css' ) ); 76 | add_action( 'bp_admin_enqueue_scripts', array( $this, 'inline_cssjs' ) ); 77 | add_action( 'bp_group_admin_edit_after', array( $this, 'admin_screen_save' ) ); 78 | 79 | // Filters 80 | add_filter( 'bp_has_groups', array( $this, 'append_need_request' ), 10, 3 ); 81 | add_filter( 'bp_get_group_join_button', array( $this, 'join_button' ), 10, 1 ); 82 | add_filter( 'bp_activity_can_comment', array( $this, 'maybe_disable_can_do' ), 10, 1 ); 83 | add_filter( 'bp_activity_can_favorite', array( $this, 'maybe_disable_can_do' ), 10, 1 ); 84 | } 85 | 86 | /** 87 | * Register an hidden post type to save custom group front pages 88 | * 89 | * @since 1.0.0 90 | */ 91 | private function register_post_type() { 92 | if ( ! bp_is_root_blog() ) { 93 | return; 94 | } 95 | 96 | $labels = array( 97 | 'name' => _x( 'Groups front', 'post type general name', 'altctrl-public-group' ), 98 | 'singular_name' => _x( 'Group front', 'post type singular name', 'altctrl-public-group' ), 99 | ); 100 | 101 | $args = array( 102 | 'labels' => $labels, 103 | 'public' => false, 104 | 'publicly_queryable' => false, 105 | 'show_ui' => false, 106 | 'show_in_menu' => false, 107 | 'query_var' => false, 108 | 'rewrite' => false, 109 | 'has_archive' => false, 110 | 'hierarchical' => true, 111 | 'supports' => array( 'editor' ) 112 | ); 113 | 114 | register_post_type( 'group_front', $args ); 115 | } 116 | 117 | /** Actions *******************************************************************/ 118 | 119 | /** 120 | * Check public group's control options and do the needed job 121 | * 122 | * @since 1.0.0 123 | */ 124 | public function control() { 125 | $bp = buddypress(); 126 | 127 | if ( ! $this->is_public_group() ) { 128 | return; 129 | } 130 | 131 | // Append to current group the control settings 132 | $hidden_tabs = (array) groups_get_groupmeta( $this->group->id, '_altctrl_tabs', true ); 133 | $need_request = apgc_group_get_visibility_level( $this->group->id ); 134 | 135 | $this->group->need_request = 'public-request' === $need_request; 136 | $this->group->need_invite = 'public-invite' === $need_request; 137 | 138 | if ( ! empty( $this->group->need_request ) && bp_is_group_admin_page() ) { 139 | bp_core_new_subnav_item( array( 140 | 'name' => __( 'Requests', 'altctrl-public-group' ), 141 | 'slug' => 'membership-requests', 142 | 'parent_url' => bp_get_groups_action_link( 'admin' ), 143 | 'parent_slug' => $this->group->slug . '_manage', 144 | 'screen_function' => 'groups_screen_group_admin', 145 | 'user_has_access' => bp_is_item_admin(), 146 | 'position' => 40 147 | ), 'groups' ); 148 | } 149 | 150 | // Managing requests 151 | if ( bp_is_group_admin_screen( 'membership-requests' ) && bp_is_item_admin() ) { 152 | $bp->groups->current_group->status = 'private'; 153 | } 154 | 155 | // Admin or members always have access 156 | if ( bp_is_item_admin() || groups_is_user_member( bp_loggedin_user_id(), $this->group->id ) ) { 157 | return; 158 | } 159 | 160 | /** Group members only tabs ***************************************************/ 161 | 162 | // Hide tabs 163 | if ( ! empty( $hidden_tabs ) ) { 164 | foreach ( $hidden_tabs as $item_tab ) { 165 | $bp->groups->nav->edit_nav( array( 'user_has_access' => false ), $item_tab, $this->group->slug ); 166 | } 167 | } 168 | 169 | // Redirect if trying to access the page 170 | if ( ! empty( $hidden_tabs ) && in_array( bp_current_action(), $hidden_tabs, true ) ) { 171 | bp_core_add_message( __( 'This area is restricted to group members', 'altctrl-public-group' ), 'error' ); 172 | bp_core_redirect( bp_get_group_permalink( $this->group ) ); 173 | } 174 | 175 | /** Joining group *************************************************************/ 176 | 177 | if ( ! empty( $this->group->need_request ) && is_user_logged_in() ) { 178 | // first add the request subnav 179 | bp_core_new_subnav_item( array( 180 | 'name' => __( 'Request Membership', 'altctrl-public-group' ), 181 | 'slug' => 'request-membership', 182 | 'parent_url' => bp_get_group_permalink( $this->group ), 183 | 'parent_slug' => $this->group->slug, 184 | 'screen_function' => 'groups_screen_group_request_membership', 185 | 'position' => 30 186 | ), 'groups' ); 187 | 188 | // Then temporarly make the group private. 189 | if ( bp_is_group_membership_request() ) { 190 | $bp->groups->current_group->status = 'private'; 191 | } 192 | } 193 | } 194 | 195 | /** 196 | * Public > fake Private > Public.. 197 | * 198 | * @since 1.0.0 199 | */ 200 | public function maybe_restore_status() { 201 | if ( ! empty( $this->group->need_request ) ) { 202 | buddypress()->groups->current_group->status = 'public'; 203 | } 204 | } 205 | 206 | /** 207 | * Inform the user his request has been taken in account 208 | * 209 | * @since 1.0.0 210 | */ 211 | public function maybe_request_info() { 212 | global $groups_template; 213 | 214 | if( ! $groups_template->group->is_pending ) { 215 | return; 216 | } 217 | ?> 218 |

    219 | is_public_group() ) { 231 | return; 232 | } 233 | 234 | $css_args = apply_filters( 'altctrl_public_group_css', array( 235 | 'handle' => 'altctrl-public-group-css', 236 | 'src' => $bp->altctrl->css_url . 'altctrl-public-group.css', 237 | 'deps' => array(), 238 | 'version' => $bp->altctrl->version, 239 | ) ); 240 | 241 | // in case admin wants to neutralize plugin's style 242 | if ( empty( $css_args ) ) { 243 | return; 244 | } 245 | 246 | wp_enqueue_style( $css_args['handle'], $css_args['src'], $css_args['deps'], $css_args['version'] ); 247 | } 248 | 249 | /** Filters *******************************************************************/ 250 | 251 | /** 252 | * Append a flag to indicate if the public group needs the user 253 | * to request a membership into the groups loop 254 | * 255 | * @since 1.0.0 256 | * 257 | * @param boolean $has_groups Whether the Groups loop contains items or not. 258 | * @param array $groups The list of found groups. 259 | * @param array $args The Groups loop arguments. 260 | * @return boolean Whether the Groups loop contains items or not. 261 | */ 262 | public function append_need_request( $has_groups, $groups, $args ) { 263 | global $groups_template; 264 | 265 | if ( bp_is_group() ) { 266 | return $has_groups; 267 | } 268 | 269 | $group_ids = wp_list_pluck( $groups->groups, 'id' ); 270 | $altctrl_metas = $this->get_request_control_meta( $group_ids ); 271 | 272 | if ( ! empty( $altctrl_metas ) ) { 273 | foreach( $groups_template->groups as $key => $group ) { 274 | 275 | if ( ! isset( $altctrl_metas[ $group->id ]->need_request ) ) { 276 | continue; 277 | } 278 | 279 | if ( 'public-request' === $altctrl_metas[ $group->id ]->need_request ) { 280 | $groups_template->groups[ $key ]->need_request = true; 281 | } elseif ( 'public-invite' === $altctrl_metas[ $group->id ]->need_request ) { 282 | $groups_template->groups[ $key ]->need_invite = true; 283 | } 284 | } 285 | } 286 | 287 | return $has_groups; 288 | } 289 | 290 | /** 291 | * Eventually change the group action buttons 292 | * 293 | * @since 1.0.0 294 | * 295 | * @param BP_Button $button The BuddyPress Group main action button. 296 | * @return BP_Button The BuddyPress Group main action button. 297 | */ 298 | public function join_button( $button ) { 299 | global $groups_template; 300 | 301 | $bail = empty( $groups_template->group->need_request ) && empty( $groups_template->group->need_invite ); 302 | 303 | if ( $bail || 'leave_group' === $button['id'] ) { 304 | return $button; 305 | } 306 | 307 | // Difficult to filter BuddyPress ajax functions, so disabling them. 308 | 309 | if ( $groups_template->group->is_invited ) { 310 | $button = array( 311 | 'id' => 'accept_invite', 312 | 'component' => 'groups', 313 | 'must_be_logged_in' => true, 314 | 'block_self' => false, 315 | 'wrapper_class' => 'no-ajax ' . $groups_template->group->status, 316 | 'wrapper_id' => 'groupbutton-' . $groups_template->group->id, 317 | 'link_href' => add_query_arg( 'redirect_to', bp_get_group_permalink( $groups_template->group ), bp_get_group_accept_invite_link( $groups_template->group ) ), 318 | 'link_text' => __( 'Accept Invitation', 'altctrl-public-group' ), 319 | 'link_title' => __( 'Accept Invitation', 'altctrl-public-group' ), 320 | 'link_class' => 'group-button accept-invite', 321 | ); 322 | } elseif ( $groups_template->group->is_pending ) { 323 | $button = array( 324 | 'id' => 'membership_requested', 325 | 'component' => 'groups', 326 | 'must_be_logged_in' => true, 327 | 'block_self' => false, 328 | 'wrapper_class' => 'no-ajax pending ' . $groups_template->group->status, 329 | 'wrapper_id' => 'groupbutton-' . $groups_template->group->id, 330 | 'link_href' => bp_get_group_permalink( $groups_template->group ), 331 | 'link_text' => __( 'Request Sent', 'altctrl-public-group' ), 332 | 'link_title' => __( 'Request Sent', 'altctrl-public-group' ), 333 | 'link_class' => 'group-button pending membership-requested', 334 | ); 335 | } elseif ( ! is_super_admin() ) { 336 | // When a request is needed: display a button to let the user request a membership 337 | if ( ! empty( $groups_template->group->need_request ) ) { 338 | $button = array( 339 | 'id' => 'request_membership', 340 | 'component' => 'groups', 341 | 'must_be_logged_in' => true, 342 | 'block_self' => false, 343 | 'wrapper_class' => 'no-ajax ' . $groups_template->group->status, 344 | 'wrapper_id' => 'groupbutton-' . $groups_template->group->id, 345 | 'link_href' => wp_nonce_url( bp_get_group_permalink( $groups_template->group ) . 'request-membership', 'groups_request_membership' ), 346 | 'link_text' => __( 'Request Membership', 'altctrl-public-group' ), 347 | 'link_title' => __( 'Request Membership', 'altctrl-public-group' ), 348 | 'link_class' => 'group-button request-membership', 349 | ); 350 | 351 | // When an invite is required: do not display the button at all. 352 | } elseif ( ! empty( $groups_template->group->need_invite ) ) { 353 | $button = false; 354 | } 355 | } 356 | 357 | return $button; 358 | } 359 | 360 | /** 361 | * If a public group needs the user to register to be a group member, commenting or 362 | * favoriting an activity is disabled 363 | * 364 | * @since 1.0.0 365 | * 366 | * @param boolean $can_do Whether the current user can perform the action. 367 | * @return boolean Whether the current user can perform the action. 368 | */ 369 | public function maybe_disable_can_do( $can_do = true ) { 370 | global $activities_template; 371 | 372 | if ( empty( $activities_template ) ) { 373 | return $can_do; 374 | } 375 | 376 | if ( is_null( $activities_template ) ) { 377 | return $can_do; 378 | } 379 | 380 | if ( 'groups' != $activities_template->activity->component ) { 381 | return $can_do; 382 | } 383 | 384 | if ( empty( $activities_template->activity->item_id ) ) { 385 | return $can_do; 386 | } 387 | 388 | if ( groups_is_user_member( bp_loggedin_user_id(), $activities_template->activity->item_id ) || is_super_admin() ) { 389 | return $can_do; 390 | } 391 | 392 | if ( empty( self::$needs_group_request ) ) { 393 | self::$needs_group_request = array(); 394 | } 395 | 396 | if ( ! isset( self::$needs_group_request[ $activities_template->activity->item_id ] ) ) { 397 | $visibility = apgc_group_get_visibility_level( $activities_template->activity->item_id ); 398 | 399 | self::$needs_group_request[ $activities_template->activity->item_id ] = ! in_array( $visibility, array( 'public-request', 'public-invite' ), true ); 400 | } 401 | 402 | $can_do = (bool) self::$needs_group_request[ $activities_template->activity->item_id ]; 403 | 404 | return $can_do; 405 | } 406 | 407 | /** Helpers *******************************************************************/ 408 | 409 | /** 410 | * Should we show the group's custom front page ? 411 | * 412 | * @since 1.0.0 413 | */ 414 | public static function show_front_page() { 415 | $retval = false; 416 | 417 | if ( bp_is_group_create() ) { 418 | return $retval; 419 | } 420 | 421 | if ( ! bp_is_group() ) { 422 | return $retval; 423 | } 424 | 425 | $group_id = bp_get_current_group_id(); 426 | 427 | if ( empty( $group_id ) ) { 428 | return $retval; 429 | } 430 | 431 | if ( bp_is_item_admin() ) { 432 | return $retval; 433 | } 434 | 435 | if ( ! groups_is_user_member( bp_loggedin_user_id(), $group_id ) && self::has_front_page( $group_id ) ) { 436 | $retval = true; 437 | } 438 | 439 | return $retval; 440 | } 441 | 442 | /** 443 | * Does the group has a custom front page ? 444 | * 445 | * @since 1.0.0 446 | * 447 | * @param integer $group_id The group ID. 448 | * @return integer The Post ID of tge custom front page. 449 | */ 450 | public static function has_front_page( $group_id = 0 ) { 451 | if ( empty( $group_id ) ) { 452 | return false; 453 | } 454 | 455 | return (int) groups_get_groupmeta( $group_id, '_altctrl_page_id', true ); 456 | } 457 | 458 | /** 459 | * Is current group, a public group ? 460 | * 461 | * @since 1.0.0 462 | */ 463 | private function is_public_group() { 464 | if ( bp_is_group() ) { 465 | $this->group = groups_get_current_group(); 466 | 467 | } elseif ( is_admin() && ! wp_doing_ajax() ) { 468 | $admin_url_query = wp_parse_args( wp_parse_url( $_SERVER['REQUEST_URI'], PHP_URL_QUERY ), array( 469 | 'page' => '', 470 | 'action' => '', 471 | 'gid' => 0, 472 | ) ); 473 | 474 | if ( 'bp-groups' === $admin_url_query['page'] && 'edit' === $admin_url_query['action'] ) { 475 | $this->group = groups_get_group( (int) $admin_url_query['gid'] ); 476 | } 477 | } 478 | 479 | if ( ! empty( $this->group->status ) ) { 480 | return 'public' === $this->group->status; 481 | } 482 | 483 | return false; 484 | } 485 | 486 | /** 487 | * Fetch all public groups that needs a membership/invites request 488 | * 489 | * @todo cache this. 490 | * 491 | * @since 1.0.0 492 | * 493 | * @param array $groups A list of group IDs. 494 | * @return object The Public groups that needs a membership/invites request. 495 | */ 496 | private function get_request_control_meta( $groups = array() ) { 497 | global $wpdb; 498 | $groupmeta_table = buddypress()->groups->table_name_groupmeta; 499 | 500 | $altctrl_metas = array(); 501 | 502 | if ( empty( $groups ) ) { 503 | return $altctrl_metas; 504 | } else { 505 | $groups = wp_parse_id_list( $groups ); 506 | } 507 | 508 | $is_meta_key = '_altctrl_visibility_level'; 509 | $group_in = "'" . implode( "','", $groups ) . "'"; 510 | 511 | $altctrl_metas = $wpdb->get_results( $wpdb->prepare( "SELECT group_id, meta_value as need_request FROM {$groupmeta_table} WHERE group_id IN ( $group_in ) AND meta_key LIKE %s", $is_meta_key ), OBJECT_K ); 512 | 513 | return $altctrl_metas; 514 | } 515 | 516 | /** Groups component API functions ********************************************/ 517 | 518 | /** 519 | * Unused 520 | */ 521 | public function create_screen( $group_id = null ) {} 522 | public function create_screen_save( $group_id = null ) {} 523 | public function display( $group_id = null ) {} 524 | public function widget_display() {} 525 | 526 | /** 527 | * Displays edit screen. 528 | * 529 | * @since 1.0.0 530 | * 531 | * @param integer $group_id The group ID. 532 | */ 533 | public function edit_screen( $group_id = null ) { 534 | $bp = buddypress(); 535 | $group_id = empty( $group_id ) ? bp_get_current_group_id() : $group_id; 536 | $page_id = absint( self::has_front_page( $group_id ) ); 537 | 538 | $tabs = groups_get_groupmeta( $group_id, '_altctrl_tabs', true ); 539 | if ( empty( $tabs ) ) { 540 | $tabs = array(); 541 | } 542 | 543 | $group_nav_items = $bp->groups->nav->get_secondary( array( 'parent_slug' => $this->group->slug ), false ); 544 | ?> 545 | 546 | 547 |

    548 | 549 |
    550 | 551 | 552 | 553 | 554 | 555 |

    556 | 557 | slug, array( 'home', 'send-invites', 'admin' ) ) ) { 559 | continue; 560 | } 561 | 562 | $item_name = preg_replace( '/([.0-9]+)/', '', $nav_item->name ); 563 | $item_name = trim( strip_tags( $item_name ) ); 564 | $item_slug = $nav_item->slug; 565 | ?> 566 |
    567 | 568 |
    569 | 572 |

    573 | 574 | 575 | 576 |
    577 | 578 |

    579 | 580 |
    581 | 582 |
    583 | 584 |
    585 | post_content; 590 | } 591 | 592 | wp_editor( $content, 'altctrl-public-group', array( 593 | 'textarea_name' => '_altctrl[page_content]', 594 | 'media_buttons' => bp_current_user_can( 'upload_files' ), 595 | 'textarea_rows' => 12, 596 | 'tinymce' => apply_filters( 'altctrl_public_group_edit_front_page', false ), 597 | 'teeny' => true, 598 | 'quicktags' => true, 599 | 'dfw' => false, 600 | ) ); 601 | ?> 602 |
    603 | 604 |
    605 | 606 | 607 | 608 | slug, 'altctrl' ); ?> 609 |
    610 | slug, 'altctrl' ); 626 | 627 | $group_id = ! empty( $group_id ) ? $group_id : bp_get_current_group_id(); 628 | 629 | // Update the visibility level. 630 | if ( isset( $_POST['_altctrl_visibility_level'] ) ) { 631 | apgc_group_update_visibility_level( $group_id, $_POST['_altctrl_visibility_level'] ); 632 | } 633 | 634 | $altctrl = array(); 635 | 636 | if ( empty( $_POST['_altctrl'] ) ) { 637 | return; 638 | } else { 639 | $altctrl = $_POST['_altctrl']; 640 | } 641 | 642 | if ( ! empty( $altctrl['tabs'] ) ) { 643 | groups_update_groupmeta( $group_id, '_altctrl_tabs', array_map( 'sanitize_title', $altctrl['tabs'] ) ); 644 | } else { 645 | groups_delete_groupmeta( $group_id, '_altctrl_tabs' ); 646 | } 647 | 648 | $page_id = $altctrl['page_id']; 649 | 650 | if ( ! empty( $altctrl['page_cb'] ) && ! empty( $altctrl['page_content'] ) ) { 651 | $page_id = wp_insert_post( array( 652 | 'ID' => $page_id, 653 | 'post_status' => 'publish', 654 | 'post_type' => 'group_front', 655 | 'post_content' => $altctrl['page_content'], 656 | ) ); 657 | 658 | update_post_meta( $page_id, '_altctrl_group_id', $group_id ); 659 | groups_update_groupmeta( $group_id, '_altctrl_page_id', $page_id ); 660 | } 661 | 662 | if ( ! empty( $altctrl['page_id'] ) && empty( $altctrl['page_cb'] ) ) { 663 | if ( wp_delete_post( $page_id ) ) { 664 | groups_delete_groupmeta( $group_id, '_altctrl_page_id', $page_id ); 665 | } 666 | } 667 | 668 | bp_core_add_message( __( 'Settings saved successfully', 'altctrl-public-group' ) ); 669 | bp_core_redirect( bp_get_group_permalink( buddypress()->groups->current_group ) . 'admin/' . $this->slug ); 670 | } 671 | 672 | /** 673 | * Add admin inline style and script for the Public group. 674 | * 675 | * @since 2.0.0 676 | */ 677 | public function inline_cssjs() { 678 | if ( is_null( $this->group ) ) { 679 | return; 680 | } 681 | 682 | wp_add_inline_style( 'bp_groups_admin_css', ' 683 | #apgc-admin ul { 684 | list-style: none; 685 | } 686 | ' ); 687 | 688 | wp_add_inline_script( 'bp_groups_admin_js', ' 689 | ( function($) { 690 | $( \'input[name="group-status"]\' ).on( \'click\', function( e ) { 691 | if ( \'public\' === $( e.currentTarget ).val() ) { 692 | $( \'#apgc-feedback\' ).addClass( \'hide-if-js hide-if-no-js\' ); 693 | $( \'#apgc-admin\' ).removeClass( \'hide-if-js hide-if-no-js\' ); 694 | } else { 695 | $( \'#apgc-feedback\' ).removeClass( \'hide-if-js hide-if-no-js\' ); 696 | $( \'#apgc-admin\' ).addClass( \'hide-if-js hide-if-no-js\' ); 697 | } 698 | } ); 699 | } )( jQuery ); 700 | ' ); 701 | } 702 | 703 | /** 704 | * Displays the Public group's control metabox 705 | * 706 | * @since 2.0.0 707 | * 708 | * @param integer $group_id The Group ID 709 | */ 710 | public function admin_screen( $group_id = null ) { 711 | ?> 712 |
    713 |

    714 |
    715 |
    716 |

    717 | 718 |
    719 | 720 | slug, 'altctrl' ); ?> 721 |
    722 | edit_screen_save( $group_id ); 738 | } 739 | 740 | /** Template tag **************************************************************/ 741 | 742 | /** 743 | * Display the group's custom front page 744 | * 745 | * @since 1.0.0 746 | */ 747 | public static function the_content() { 748 | $group_id = bp_get_current_group_id(); 749 | 750 | if ( empty( $group_id ) ) { 751 | return; 752 | } 753 | 754 | $page_id = groups_get_groupmeta( $group_id, '_altctrl_page_id', true ); 755 | 756 | if ( empty( $page_id ) ) { 757 | return; 758 | } 759 | 760 | $page = get_post( $page_id ); 761 | $output = apply_filters( 'the_content', $page->post_content ); 762 | 763 | echo apply_filters( 'altctrl_public_group_display_front_page', $output ); 764 | } 765 | } 766 | 767 | endif; 768 | --------------------------------------------------------------------------------