The following privileges are required for Piwik to run: - CREATE - ALTER - SELECT - INSERT - UPDATE - DELETE - DROP - CREATE TEMPORARY TABLES
Inheritance: extends HTML_QuickForm2_Rul\HTML_QuickForm2_Rule
コード例 #1
0
ファイル: FormDatabaseSetup.php プロジェクト: imreFitos/piwik
 function init()
 {
     HTML_QuickForm2_Factory::registerRule('checkValidFilename', 'Piwik\\Plugins\\Installation\\FormDatabaseSetup_Rule_checkValidFilename');
     $checkUserPrivilegesClass = 'Piwik\\Plugins\\Installation\\Rule_checkUserPrivileges';
     HTML_QuickForm2_Factory::registerRule('checkUserPrivileges', $checkUserPrivilegesClass);
     $availableAdapters = Adapter::getAdapters();
     $adapters = array();
     foreach ($availableAdapters as $adapter => $port) {
         $adapters[$adapter] = $adapter;
     }
     $types = array('InnoDB' => 'InnoDB');
     $this->addElement('text', 'host')->setLabel(Piwik::translate('Installation_DatabaseSetupServer'))->addRule('required', Piwik::translate('General_Required', Piwik::translate('Installation_DatabaseSetupServer')));
     $user = $this->addElement('text', 'username')->setLabel(Piwik::translate('Installation_DatabaseSetupLogin'));
     $user->addRule('required', Piwik::translate('General_Required', Piwik::translate('Installation_DatabaseSetupLogin')));
     $requiredPrivileges = Rule_checkUserPrivileges::getRequiredPrivilegesPretty();
     $user->addRule('checkUserPrivileges', Piwik::translate('Installation_InsufficientPrivilegesMain', $requiredPrivileges . '<br/><br/>') . Piwik::translate('Installation_InsufficientPrivilegesHelp'));
     $this->addElement('password', 'password')->setLabel(Piwik::translate('General_Password'));
     $item = $this->addElement('text', 'dbname')->setLabel(Piwik::translate('Installation_DatabaseSetupDatabaseName'));
     $item->addRule('required', Piwik::translate('General_Required', Piwik::translate('Installation_DatabaseSetupDatabaseName')));
     $item->addRule('checkValidFilename', Piwik::translate('General_NotValid', Piwik::translate('Installation_DatabaseSetupDatabaseName')));
     $this->addElement('text', 'tables_prefix')->setLabel(Piwik::translate('Installation_DatabaseSetupTablePrefix'))->addRule('checkValidFilename', Piwik::translate('General_NotValid', Piwik::translate('Installation_DatabaseSetupTablePrefix')));
     $this->addElement('select', 'adapter')->setLabel(Piwik::translate('Installation_DatabaseSetupAdapter'))->loadOptions($adapters)->addRule('required', Piwik::translate('General_Required', Piwik::translate('Installation_DatabaseSetupAdapter')));
     $this->addElement('select', 'type')->setLabel(Piwik::translate('Installation_DatabaseSetupDatabaseEngine'))->loadOptions($types)->addRule('required', Piwik::translate('General_Required', Piwik::translate('Installation_DatabaseSetupDatabaseEngine')));
     $this->addElement('submit', 'submit', array('value' => Piwik::translate('General_Next') . ' »', 'class' => 'submit'));
     // default values
     $this->addDataSource(new HTML_QuickForm2_DataSource_Array(array('host' => '127.0.0.1', 'tables_prefix' => 'piwik_')));
 }
コード例 #2
0
 function init()
 {
     HTML_QuickForm2_Factory::registerRule('checkValidFilename', 'Piwik\\Plugins\\Installation\\FormDatabaseSetup_Rule_checkValidFilename');
     HTML_QuickForm2_Factory::registerRule('checkValidDbname', 'Piwik\\Plugins\\Installation\\FormDatabaseSetup_Rule_checkValidDbname');
     HTML_QuickForm2_Factory::registerRule('checkUserPrivileges', 'Piwik\\Plugins\\Installation\\Rule_checkUserPrivileges');
     $availableAdapters = Adapter::getAdapters();
     $adapters = array();
     foreach ($availableAdapters as $adapter => $port) {
         $adapters[$adapter] = $adapter;
         if (Adapter::isRecommendedAdapter($adapter)) {
             $adapters[$adapter] .= ' (' . Piwik::translate('General_Recommended') . ')';
         }
     }
     $this->addElement('text', 'host')->setLabel(Piwik::translate('Installation_DatabaseSetupServer'))->addRule('required', Piwik::translate('General_Required', Piwik::translate('Installation_DatabaseSetupServer')));
     $user = $this->addElement('text', 'username')->setLabel(Piwik::translate('Installation_DatabaseSetupLogin'));
     $user->addRule('required', Piwik::translate('General_Required', Piwik::translate('Installation_DatabaseSetupLogin')));
     $requiredPrivileges = Rule_checkUserPrivileges::getRequiredPrivilegesPretty();
     $user->addRule('checkUserPrivileges', Piwik::translate('Installation_InsufficientPrivilegesMain', $requiredPrivileges . '<br/><br/>') . Piwik::translate('Installation_InsufficientPrivilegesHelp'));
     $this->addElement('password', 'password')->setLabel(Piwik::translate('General_Password'));
     $item = $this->addElement('text', 'dbname')->setLabel(Piwik::translate('Installation_DatabaseSetupDatabaseName'));
     $item->addRule('required', Piwik::translate('General_Required', Piwik::translate('Installation_DatabaseSetupDatabaseName')));
     $item->addRule('checkValidDbname', Piwik::translate('General_NotValid', Piwik::translate('Installation_DatabaseSetupDatabaseName')));
     $this->addElement('text', 'tables_prefix')->setLabel(Piwik::translate('Installation_DatabaseSetupTablePrefix'))->addRule('checkValidFilename', Piwik::translate('General_NotValid', Piwik::translate('Installation_DatabaseSetupTablePrefix')));
     $this->addElement('select', 'adapter')->setLabel(Piwik::translate('Installation_DatabaseSetupAdapter'))->loadOptions($adapters)->addRule('required', Piwik::translate('General_Required', Piwik::translate('Installation_DatabaseSetupAdapter')));
     $this->addElement('submit', 'submit', array('value' => Piwik::translate('General_Next') . ' »', 'class' => 'btn'));
     $defaultDatabaseType = Config::getInstance()->database['type'];
     $this->addElement('hidden', 'type')->setLabel('Database engine');
     // default values
     $this->addDataSource(new HTML_QuickForm2_DataSource_Array(array('host' => $_ENV["SQLHOST"] . ':' . $_ENV["SQLPORT"], 'username' => $_ENV["SQLUSER"], 'password' => $_ENV["SQLPASSWORD"], 'dbname' => $_ENV["SQLDB"], 'type' => $defaultDatabaseType, 'tables_prefix' => 'piwik_')));
 }