diff --git a/src/client/app/js/app/core/Dict.js b/src/client/app/js/app/core/Dict.js index 5a45f84..2ce1455 100644 --- a/src/client/app/js/app/core/Dict.js +++ b/src/client/app/js/app/core/Dict.js @@ -240,7 +240,10 @@ app.core.Dict = { "EDIT_GROUP" : "Gruppe bearbeiten", "GROUP_NAME" : "Gruppenname", "GROUP_DESCRIPTION" : "Beschreibung", - "GROUP_TERMS": "Nutzungsbedingungn", + "GROUP_TERMS": "Nutzungsbedingungen", + "GROUP_TERMS_ACCEPT": "akzeptieren", + "GROUP_TERMS_ACCEPTED": "Du hast die Nutzungsbedingungen akzeptiert", + "GROUP_TERMS_NOT_ACCEPTED": "Du hast die Nutzungsbedingungen nicht akzeptiert", "GROUP_TERMS_DESCRIPTION": "Begrüßung und Nutzungsbedingungen", "GROUP_TERMS_ACTIVE": "Nutzungsbedingungen aktiv", "GROUP_TERMS_ACTIVE_DESCRIPTION": "Wenn die Nutzungsbedingungen aktiv sind, müssen Gruppenmitglieder diese aktiv akzeptieren um weiter aktiv an Terminen teilnehmen zu können.", diff --git a/src/client/app/js/app/state/GroupTermsConditions.js b/src/client/app/js/app/state/GroupTermsConditions.js index 1ff5582..a727e58 100644 --- a/src/client/app/js/app/state/GroupTermsConditions.js +++ b/src/client/app/js/app/state/GroupTermsConditions.js @@ -27,7 +27,7 @@ app.state.GroupTermsConditions = function() app.core.View.setContent( app.core.View.getTemplate( - 'group-setting', + 'group-terms', { group: mGroup, currentProfile: app.model.SessionUser.getUserProfile() @@ -40,7 +40,23 @@ app.state.GroupTermsConditions = function() app.core.View.toastSuccess( _lc( 'CALENDER_LINK_COPIED' ) ); }); + $content.find( '[data-id="checkbox-terms-conditions-accept"]' ).first().change( function() + { + let accepted = $content.find( '[data-id="checkbox-terms-conditions-accept"]' ).find('[data-id="checkbox-terms-conditions-accept"]').first().is(":checked"); + console.log(accepted); + app.core.Rpc.call( + 'Profile', + 'acceptTerms', + { groupId: groupId, termsAccepted: accepted }, + function( res ) + { + app.core.View.toastSuccess( _lc( accepted ? 'GROUP_TERMS_ACCEPTED' : 'GROUP_TERMS_NOT_ACCEPTED' ) ); + }, + function ( res ){ + app.core.View.toastError( _lc( 'GENERAL_SERVER_ERROR' ) ); + }); + }); app.gui.PageLoader.hide(); } ); diff --git a/src/client/app/tmpl/group-terms.html b/src/client/app/tmpl/group-terms.html index bf8b468..b62a5ee 100644 --- a/src/client/app/tmpl/group-terms.html +++ b/src/client/app/tmpl/group-terms.html @@ -17,22 +17,25 @@

<%= _lc( 'GROUP_TERMS_DESCRIPTION' ) %>

+ + <% if ( group.getTermsConditionsActive() ) { %> + + <% } %> +

- <%= _lc( 'GROUP_TERMS_ACTIVE_DESCRIPTION' ) %> -

-
- -
+ <%= _lc( 'GROUP_TERMS_ACTIVE_DESCRIPTION' ) %> diff --git a/src/server/server/control/TB_Server_Control_Profile.php b/src/server/server/control/TB_Server_Control_Profile.php index 4e8864b..0bc4d65 100644 --- a/src/server/server/control/TB_Server_Control_Profile.php +++ b/src/server/server/control/TB_Server_Control_Profile.php @@ -628,4 +628,24 @@ class TB_Server_Control_Profile { { return self::delete( $params ); } + + public static function acceptTerms ( TB_Server_Core_RequestData $params ) + { + $resp = new TB_Server_Core_Response(); + + $groupId = $params->get( 'groupId' ); + $termsAccepted = $params->get( 'termsAccepted' ); + + /** @var TB_Shared_Ent_TeamData_Profile $profile */ + $profile = TB_Server_Core_Session::get()->getProfile(); + + if (!$profile->isInTeam($groupId)) { + throw new \Exception( 'Profile not in team.' ); + } + + $profile->setTermsConditionAccepted($groupId, $termsAccepted); + $profile->save(); + + return $resp; + } } \ No newline at end of file