Commit c52642097e002acedf88541ffa08af6b525b74ee

Authored by Jarrett Jordaan
1 parent 16c973ec

PT:1965737: Generate dms users passwords.

Committed by: Jarrett Jordaan

Reviewed by: Megan Watson
setup/wizard/steps/database.php
... ... @@ -150,22 +150,13 @@ class database extends Step
150 150 private $dmsuserpassword = '';
151 151  
152 152 /**
153   - * Location of database binaries.
154   - *
155   - * @author KnowledgeTree Team
156   - * @access private
157   - * @var string
158   - */
159   - private $mysqlDir; // TODO:multiple databases
160   -
161   - /**
162 153 * Name of database binary.
163 154 *
164 155 * @author KnowledgeTree Team
165 156 * @access private
166 157 * @var string
167 158 */
168   - private $dbbinary = ''; // TODO:multiple databases
  159 + private $dbbinary = '';
169 160  
170 161 /**
171 162 * Database table prefix
... ... @@ -230,7 +221,7 @@ class database extends Step
230 221 */
231 222 protected $silent = true;
232 223  
233   - private $salt = 'installers';
  224 + //protected $salt = 'installers';
234 225  
235 226 /**
236 227 * Main control of database setup
... ... @@ -284,7 +275,8 @@ class database extends Step
284 275 $this->setPostConfig(); // Set any posted variables
285 276 return 'next';
286 277 } else if($this->edit()) {
287   - $this->setDataFromSession("database"); // Set Session Information, since its an edit
  278 + if($this->setDataFromSession("database")) // Set Session Information, since its an edit
  279 + $this->setDetails(); // Set any posted variables
288 280 $this->temp_variables['state'] = 'edit';
289 281  
290 282 return 'landing';
... ... @@ -363,8 +355,8 @@ class database extends Step
363 355 * @return boolean
364 356 */
365 357 private function setErrorsFromSession() {
366   - if(isset($_SESSION[$this->salt]['database']['errors'])) {
367   - $this->error[] = $_SESSION[$this->salt]['database']['errors'];
  358 + if(isset($_SESSION['installers']['database']['errors'])) {
  359 + $this->error[] = $_SESSION['installers']['database']['errors'];
368 360  
369 361 return true;
370 362 }
... ... @@ -382,7 +374,7 @@ class database extends Step
382 374 */
383 375 public function setPostConfig() {
384 376 $this->dtype = $this->getPostSafe("dtype");
385   - $this->dtypes = array("0"=>"mysql"); // TODO:multiple databases
  377 + $this->dtypes = array("0"=>"mysql");
386 378 $this->dhost = $this->getPostSafe("dhost");
387 379 $this->dport = $this->getPostSafe("dport");
388 380 $this->dname = $this->getPostSafe("dname");
... ... @@ -408,7 +400,7 @@ class database extends Step
408 400 public function loadDefaults($simplexml) {
409 401 if($simplexml) {
410 402 $this->temp_variables['dtype'] = "";
411   - $this->temp_variables['dtypes'] = array("0"=>"mysql"); // TODO:multiple databases
  403 + $this->temp_variables['dtypes'] = array("0"=>"mysql");
412 404 $this->temp_variables['dname'] = (string) $simplexml->dname;
413 405 $this->temp_variables['duname'] = (string) $simplexml->duname;
414 406 $this->temp_variables['dhost'] = (string) $simplexml->dhost;
... ... @@ -416,8 +408,8 @@ class database extends Step
416 408 $this->temp_variables['dpassword'] = '';
417 409 $this->temp_variables['dmsname'] = (string) $simplexml->dmsadminuser;
418 410 $this->temp_variables['dmsusername'] = (string) $simplexml->dmsuser;
419   - $this->temp_variables['dmspassword'] = (string) $simplexml->dmsaupass;
420   - $this->temp_variables['dmsuserpassword'] = (string) $simplexml->dmsupass;
  411 + $this->temp_variables['dmspassword'] = substr(md5(rand()), 0, 9);
  412 + $this->temp_variables['dmsuserpassword'] = substr(md5(rand()), 0, 9);
421 413 if(WINDOWS_OS) {
422 414 $this->temp_variables['dbbinary'] = 'mysql.exe';
423 415 } else {
... ... @@ -445,7 +437,7 @@ class database extends Step
445 437 $this->temp_variables['state'] = '';
446 438 }
447 439 $this->temp_variables['dtype'] = $this->getPostSafe('dtype');
448   - $this->temp_variables['dtypes'] = array("0"=>"mysql"); // TODO:multiple databases;
  440 + $this->temp_variables['dtypes'] = array("0"=>"mysql");
449 441 $this->temp_variables['dhost'] = $this->getPostSafe('dhost');
450 442 $this->temp_variables['dport'] = $this->getPostSafe('dport');
451 443 $this->temp_variables['dname'] = $this->getPostSafe('dname');
... ... @@ -771,16 +763,34 @@ class database extends Step
771 763 $dbMigrate = $this->util->getDataFromPackage('migrate', 'database');
772 764 $sqlFile = $dbMigrate['dumpLocation'];
773 765 $this->parse_mysql_dump($sqlFile);
774   - $dropPluginHelper = "TRUNCATE plugin_helper;"; // Remove plugin helper table
775   - $this->util->dbUtilities->query($dropPluginHelper);
  766 + $this->prepDatabase();
  767 +
  768 + return true;
  769 + }
  770 +
  771 + private function prepDatabase() {
  772 + $this->truncatePluginHelper();
  773 + $this->truncateActiveSessions();
776 774 $this->addServerPort();
777   - $updateExternalBinaries = 'UPDATE config_settings c SET c.value = "default" where c.group_name = "externalBinary";'; // Remove references to old paths
778   - $this->util->dbUtilities->query($updateExternalBinaries);
  775 + $this->updateConfigSettings();
779 776 $this->reBuildPaths();
780 777 $this->writeBinaries(); // Rebuild some of the binaries
781   - $this->util->getSystemIdentifier(); // ensure a guid was generated and is stored
782   -
783   - return true;
  778 + $this->util->getSystemIdentifier(); // ensure a guid was generated and is stored
  779 + }
  780 +
  781 + private function truncateActiveSessions() {
  782 + $dropActiveSessions = "TRUNCATE active_sessions;"; // Remove plugin helper table
  783 + $this->util->dbUtilities->query($dropActiveSessions);
  784 + }
  785 +
  786 + private function truncatePluginHelper() {
  787 + $dropPluginHelper = "TRUNCATE plugin_helper;"; // Remove plugin helper table
  788 + $this->util->dbUtilities->query($dropPluginHelper);
  789 + }
  790 +
  791 + private function updateConfigSettings() {
  792 + $updateExternalBinaries = 'UPDATE config_settings c SET c.value = "default" where c.group_name = "externalBinary";'; // Remove references to old paths
  793 + $this->util->dbUtilities->query($updateExternalBinaries);
784 794 }
785 795  
786 796 private function reBuildPaths() {
... ...
setup/wizard/templates/database.tpl
... ... @@ -21,7 +21,6 @@
21 21 $input_size = '45';
22 22 $align = 'left';
23 23 ?>
24   -<!-- TODO: Different Databases-->
25 24 <?php if($state != 'edit') { ?>
26 25 <tr><td>Your current database type is: </td>
27 26 <?php if($dtypes) {
... ... @@ -86,7 +85,6 @@
86 85 <input type="button" name="Next" value="Next" onclick="javascript:{w.showStep(1, 'n');}" class="button_next"/>
87 86 <?php } ?>
88 87 </div>
89   -
90 88 <!-- STEP 2 of the database configuration - Admin user password settings -->
91 89 <div id="database" class="step2" style="display:none;">
92 90 <div class="description">
... ... @@ -114,7 +112,6 @@ An administrative user is required for creating tables within the database.
114 112 <input type="button" name="Previous" value="Previous" onclick="javascript:{w.showStep(2, 'p');}" class="button_previous"/>
115 113 <input type="button" name="Next" value="Next" onclick="javascript:{w.showStep(2, 'n');}" class="button_next"/>
116 114 </div>
117   -
118 115 <!-- STEP 3 of the database configuration - default user password settings -->
119 116 <div id="database" class="step3" style="display:none;">
120 117 <div class="description">
... ...
setup/wizard/templates/database_confirm.tpl
1 1 <form id="services_database_registration" action="index.php?step_name=<?php echo $step_name; ?>" method="post">
2 2 <p class="title">Confirming Database Configurations</p>
3   -
4 3 <div class="description">
5 4 Confirm whether KnowledgeTree has correctly determined your database settings before proceeding. Print this page for future use. <a href="javascript:window.print()">Click to Print This Page</a>
6 5 </div>
... ... @@ -41,9 +40,7 @@
41 40 </tr>
42 41 <?php } ?>
43 42 </table>
44   - <!--</div>-->
45 43 <h3><b>Advanced Settings</b></h3>
46   -
47 44 <table class="dbconf">
48 45 <tr>
49 46 <td width="153px">Host: </td>
... ... @@ -68,29 +65,23 @@
68 65 </tr>
69 66 <?php } ?>
70 67 </table>
71   -
72 68 <h3><b>Database Users (System Generated)</b></h3>
73   -
74 69 <table class="dbconf">
75   - <?php //if (!$silent) { ?>
76 70 <tr>
77 71 <td width="153px">DMS Admin Username: </td>
78 72 <td width="15px"> <div id="tooltips" title="Database Administrative User for KnowledgeTree System">&nbsp;</div> </td>
79 73 <td><?php echo $dmsname; ?></td>
80 74 </tr>
81   - <?php //} ?>
82 75 <tr>
83 76 <td>DMS Admin Password: </td>
84 77 <td> <div id="tooltips" title="Database Administrative User password">&nbsp;</div> </td>
85 78 <td><?php echo $dmspassword; ?></td>
86 79 </tr>
87   - <?php //if (!$silent) { ?>
88 80 <tr>
89 81 <td>DMS User Username: </td>
90 82 <td> <div id="tooltips" title="Database User for KnowledgeTree System">&nbsp;</div> </td>
91 83 <td><?php echo $dmsusername; ?></td>
92 84 </tr>
93   - <?php //} ?>
94 85 <tr>
95 86 <td>DMS User Password: </td>
96 87 <td> <div id="tooltips" title="Database User password">&nbsp;</div> </td>
... ...