Welcome to mirror list, hosted at ThFree Co, Russian Federation.

FormGeneralSetup.php « Installation « plugins - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8d1f23a5c1676f9136d8b1bd8377385902288e4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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
93
94
95
96
97
98
99
<?php
/**
 * Piwik - Open source web analytics
 * 
 * @link http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 * 
 * @category Piwik_Plugins
 * @package Piwik_Installation
 */

/**
 * 
 * @package Piwik_Installation
 */
class Piwik_Installation_FormGeneralSetup extends Piwik_QuickForm2
{
	function __construct( $id = 'generalsetupform', $method = 'post', $attributes = null, $trackSubmit = false)
	{
		parent::__construct($id,  $method, $attributes = array('autocomplete' => 'off'), $trackSubmit);
	}

	function init()
	{
		HTML_QuickForm2_Factory::registerRule('checkLogin', 'Piwik_Installation_FormGeneralSetup_Rule_isValidLoginString');
		HTML_QuickForm2_Factory::registerRule('checkEmail', 'Piwik_Installation_FormGeneralSetup_Rule_isValidEmailString');

		$login = $this->addElement('text', 'login')
		              ->setLabel(Piwik_Translate('Installation_SuperUserLogin'));
		$login->addRule('required', Piwik_Translate('General_Required', Piwik_Translate('Installation_SuperUserLogin')));
		$login->addRule('checkLogin');

		$password = $this->addElement('password', 'password')
		                 ->setLabel(Piwik_Translate('Installation_Password'));
		$password->addRule('required', Piwik_Translate('General_Required', Piwik_Translate('Installation_Password')));

		$passwordBis = $this->addElement('password', 'password_bis')
		     ->setLabel(Piwik_Translate('Installation_PasswordRepeat'));
		$passwordBis->addRule('required', Piwik_Translate('General_Required', Piwik_Translate('Installation_PasswordRepeat')));
		$passwordBis->addRule('eq', Piwik_Translate( 'Installation_PasswordDoNotMatch'), $password);

		$email = $this->addElement('text', 'email')
		              ->setLabel(Piwik_Translate('Installation_Email'));
		$email->addRule('required', Piwik_Translate('General_Required', Piwik_Translate('Installation_Email')));
		$email->addRule('checkEmail', Piwik_Translate( 'UsersManager_ExceptionInvalidEmail'));

		$this->addElement('checkbox', 'subscribe_newsletter_security', null, array(
			'content' => '&nbsp;&nbsp;' . Piwik_Translate('Installation_SecurityNewsletter'),
		));

		$this->addElement('checkbox', 'subscribe_newsletter_community', null, array(
			'content' => '&nbsp;&nbsp;' . Piwik_Translate('Installation_CommunityNewsletter'),
		));

		$this->addElement('submit', 'submit', array('value' => Piwik_Translate('General_Next').' »', 'class' => 'submit'));

		// default values
		$this->addDataSource(new HTML_QuickForm2_DataSource_Array(array(
			'subscribe_newsletter_community' => 1,
			'subscribe_newsletter_security' => 1,
		)));
	}
}

/**
 * Login id validation rule
 *
 * @package Piwik_Installation
 */
class Piwik_Installation_FormGeneralSetup_Rule_isValidLoginString extends HTML_QuickForm2_Rule
{
	function validateOwner()
	{
		try {
    		$login = $this->owner->getValue();
    		if(!empty($login))
    		{
    			Piwik::checkValidLoginString($login);
    		}
		} catch(Exception $e) {
			$this->setMessage($e->getMessage());
			return false;
		}
		return true;
	}
}

/**
 * Email address validation rule
 *
 * @package Piwik_Installation
 */
class Piwik_Installation_FormGeneralSetup_Rule_isValidEmailString extends HTML_QuickForm2_Rule
{
	function validateOwner()
	{
		return Piwik::isValidEmailString($this->owner->getValue());
	}
}