1: <?php
2: /**
3: * Login tasks module that presents a TOS Agreement page to user.
4: * If user does not accept terms, user is not allowed to login.
5: *
6: * Copyright 2002-2012 Horde LLC (http://www.horde.org/)
7: *
8: * See the enclosed file COPYING for license information (GPL). If you
9: * did not receive this file, see http://www.horde.org/licenses/gpl.
10: *
11: * @author Michael Slusarz <slusarz@horde.org>
12: * @category Horde
13: * @license http://www.horde.org/licenses/gpl GPL
14: * @package Horde
15: */
16: class Horde_LoginTasks_Task_TosAgreement extends Horde_LoginTasks_Task
17: {
18: /**
19: * The interval at which to run the task.
20: *
21: * @var integer
22: */
23: public $interval = Horde_LoginTasks::FIRST_LOGIN;
24:
25: /**
26: * The style of the page output.
27: *
28: * @var integer
29: */
30: public $display = Horde_LoginTasks::DISPLAY_AGREE;
31:
32: /**
33: * The priority of the task.
34: *
35: * @var integer
36: */
37: public $priority = Horde_LoginTasks::PRIORITY_HIGH;
38:
39: /**
40: * Constructor.
41: */
42: public function __construct()
43: {
44: global $conf;
45:
46: $this->active = false;
47:
48: if (!empty($conf['tos']['file'])) {
49: if (file_exists($conf['tos']['file'])) {
50: $this->active = true;
51: } else {
52: Horde::logMessage('Terms of Service Agreement file was not found: ' . $conf['tos']['file'], 'ERR');
53: }
54: }
55: }
56:
57: /**
58: * Determine if user agreed with the terms or not. If the user does not
59: * agree, log him/her out immediately.
60: */
61: public function execute()
62: {
63: if (Horde_Util::getFormData('not_agree')) {
64: $GLOBALS['registry']->authenticateFailure('horde', new Horde_Exception(_("You did not agree to the Terms of Service agreement, so you were not allowed to login."), Horde_Registry::PERMISSION_DENIED));
65: }
66: }
67:
68: /**
69: * Returns the TOS agreement for display on the login tasks page.
70: *
71: * @return string The terms of service agreement.
72: */
73: public function describe()
74: {
75: return file_get_contents($GLOBALS['conf']['tos']['file']);
76: }
77:
78: }
79: