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: a1b62aaaf994215d945420a77d0ee78864e56e53 (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
<?php
/**
 * Piwik - Open source web analytics
 * 
 * @link http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later
 * @version $Id$
 * 
 * @category Piwik_Plugins
 * @package Piwik_Installation
 */

/**
 * 
 * @package Piwik_Installation
 */
class Piwik_Installation_FormGeneralSetup extends Piwik_Form
{
	function __construct()
	{
		parent::__construct($action = '', $attributes = 'autocomplete="off"');
	}
	
	function validate()
	{
		try {
    		$login = $this->getSubmitValue('login');
    		if(!empty($login))
    		{
    			Piwik::checkValidLoginString($login);
    		}
		} catch(Exception $e) {
			$this->_errors['login'] = $e->getMessage();
		}
		return parent::validate();
	}
	
	function init()
	{
		$urlToGoAfter = 'index.php' . Piwik_Url::getCurrentQueryString();

		$formElements = array(
			array('text', 'login', Piwik_Translate('Installation_SuperUserLogin')),
			array('password', 'password', Piwik_Translate('Installation_Password')),
			array('password', 'password_bis', Piwik_Translate('Installation_PasswordRepeat')),
			array('text', 'email', Piwik_Translate('Installation_Email')),
			array('checkbox', 'subscribe_newsletter_security', '', '&nbsp;&nbsp;' . Piwik_Translate('Installation_SecurityNewsletter')),
			array('checkbox', 'subscribe_newsletter_community', '', '&nbsp;&nbsp;'. Piwik_Translate('Installation_CommunityNewsletter')),
		);
		$this->addElements( $formElements );
		
		if(!$this->isSubmitted()
			|| $this->getSubmitValue('subscribe_newsletter_community') == '1')
		{
			$this->setChecked('subscribe_newsletter_community');
		}
		if(!$this->isSubmitted()
			|| $this->getSubmitValue('subscribe_newsletter_security') == '1')
		{
			$this->setChecked('subscribe_newsletter_security');
		}
		
		$formRules = array();
		foreach($formElements as $row)
		{
			// checkboxes are not required (form should validate when unchecked)
			if(in_array($row[1],array('subscribe_newsletter_security','subscribe_newsletter_community')))
			{
				continue;
			}
			$formRules[] = array($row[1], Piwik_Translate('General_Required', $row[2]), 'required');
		}
		
		$formRules[] = array( 	'email', 
								Piwik_Translate( 'UsersManager_ExceptionInvalidEmail'), 
								'checkEmail'
		);
		$formRules[] = array( 	'password',
								Piwik_Translate( 'Installation_PasswordDoNotMatch'),
								'fieldHaveSameValue',
								'password_bis'
		);
		
		$this->addRules( $formRules );	
		$this->addElement('submit', 'submit', Piwik_Translate('Installation_SubmitGo'));
	}	
}