Permalink
Browse files

Update Disclaimer plugin, especially regarding behaviour in shared li…

…nks.
  • Loading branch information...
1 parent c426eb0 commit 78c39a9140b16ef5397e54b442fe5ff38b1f7a5c @cdujeu cdujeu committed Jun 29, 2016
@@ -23,6 +23,8 @@
use Pydio\Core\Http\Middleware\SessionMiddleware;
use Pydio\Core\Http\Middleware\SessionRepositoryMiddleware;
+use Pydio\Core\Model\ContextInterface;
+use Pydio\Core\Model\UserInterface;
use Pydio\Core\Services\AuthService;
use Pydio\Core\Services\ConfService;
use Pydio\Core\PluginFramework\Plugin;
@@ -35,12 +37,14 @@
defined('AJXP_EXEC') or die('Access not allowed');
/**
- * Simple implementation for forcing using to accept a disclaimer
+ * Implementation for forcing using to accept a disclaimer
*/
class DisclaimerProvider extends Plugin
{
/**
+ * Set disclaimer validation on/off
+ *
* @param ServerRequestInterface $request
* @param ResponseInterface $response
* @throws \Pydio\Core\Exception\AuthRequiredException
@@ -86,6 +90,8 @@ public function toggleDisclaimer(ServerRequestInterface &$request, ResponseInter
}
/**
+ * Serve the content of the Dicsclaimer.
+ *
* @param ServerRequestInterface $request
* @param ResponseInterface $response
*/
@@ -100,4 +106,37 @@ public function loadDisclaimer(ServerRequestInterface &$request, ResponseInterfa
}
+ /**
+ * Hooked to user.after_create
+ * Is disabled on shared links, this will automatically validate the disclaimer
+ * for any new shared user created .
+ *
+ * @param ContextInterface $ctx
+ * @param UserInterface $userObject
+ */
+ public function updateSharedUser(ContextInterface $ctx, UserInterface $userObject){
+ if($userObject->isHidden() && !$this->getContextualOption($ctx, "DISCLAIMER_ENABLE_SHARED")){
+ $userObject->removeLock();
+ $userObject->getPersonalRole()->setParameterValue("action.disclaimer", "DISCLAIMER_ACCEPTED", "yes", AJXP_REPO_SCOPE_SHARED);
+ $userObject->save("superuser");
+ }
+ }
+
+ /**
+ * Hooked to user.after_login
+ * If enabled on shared links, this will always reset the validation to false just after login.
+ * Validation should be ok during the session, then disabled next time the link is loaded.
+ *
+ * @param ContextInterface $ctx
+ * @param UserInterface $userObject
+ */
+ public function updateSharedUserLogin(ContextInterface $ctx, UserInterface $userObject){
+ if($userObject->isHidden() && $this->getContextualOption($ctx, "DISCLAIMER_ENABLE_SHARED")){
+ $userObject->setLock("validate_disclaimer");
+ $userObject->getPersonalRole()->setParameterValue("action.disclaimer", "DISCLAIMER_ACCEPTED", "no", AJXP_REPO_SCOPE_SHARED);
+ $userObject->save("superuser");
+ }
+ }
+
}
+
@@ -13,6 +13,8 @@
<param name="DISCLAIMER_ACCEPTED" type="select" group="CONF_MESSAGE[Disclaimer]" choices="yes|CONF_MESSAGE[Accepted],no|CONF_MESSAGE[Not Accepted]" label="CONF_MESSAGE[Validation]"
scope="user,group,role"
description="CONF_MESSAGE[Whether the user has accepted the disclaimer or not]" default="no"/>
+ <global_param name="DISCLAIMER_ENABLE_SHARED" type="boolean" label="CONF_MESSAGE[Enable for public links]"
+ description="CONF_MESSAGE[Enable disclaimer for public links. if enabled, it will require disclaimer validation on each public link load, even if a user already accessed the link.]" default="false"/>
<global_param name="DISCLAIMER_CONTENT" type="textarea" label="CONF_MESSAGE[Disclaimer Content]"
description="CONF_MESSAGE[You can use HTML]" default=""/>
</server_settings>
@@ -75,6 +77,10 @@
</processing>
</action>
</actions>
+ <hooks>
+ <serverCallback methodName="updateSharedUser" hookName="user.after_create"/>
+ <serverCallback methodName="updateSharedUserLogin" hookName="user.after_login"/>
+ </hooks>
</registry_contributions>
<class_definition filename="plugins/action.disclaimer/DisclaimerProvider.php" classname="Pydio\Action\Disclaimer\DisclaimerProvider"/>
</ajxp_plugin>
@@ -1 +1,13 @@
-<p>Get user avatar from Gravatar, based on email address.</p>
+<p>Disclaimer plugin allows you to force your users to validate any usage conditions of the platform before being able to access it.</p>
+
+<h4>Enabling Disclaimer</h4>
+<p>Once enable, you have to update the Root Group (or any sub group) by switching <b>"Disclaimer Validated"</b> to <em>"No"</em>, and
+ manually type in the following value in the <b>Users Lock</b> field : "validate_disclaimer" (without quotes). That setting will be propagated
+ to all users of the group, and then each user will have its lock/disclaimer parameter updated when they will sign it and accept it.
+</p>
+
+<h4>Shares Behaviour</h4>
+<ul>Regarding shared links, there are two options:
+ <li>. <b>Enable Shared Links</b>: disclaimer will be enabled and displayed <b>each time</b> a link is loaded, even if a user already accessed this link previously.</li>
+ <li>. <b>Disable Shared Links</b>: no disclaimer will be shown (shared users are automatically "validated" on creation).</li>
+</ul>

0 comments on commit 78c39a9

Please sign in to comment.