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,22 +150,13 @@ class database extends Step
150 private $dmsuserpassword = ''; 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 * Name of database binary. 153 * Name of database binary.
163 * 154 *
164 * @author KnowledgeTree Team 155 * @author KnowledgeTree Team
165 * @access private 156 * @access private
166 * @var string 157 * @var string
167 */ 158 */
168 - private $dbbinary = ''; // TODO:multiple databases 159 + private $dbbinary = '';
169 160
170 /** 161 /**
171 * Database table prefix 162 * Database table prefix
@@ -230,7 +221,7 @@ class database extends Step @@ -230,7 +221,7 @@ class database extends Step
230 */ 221 */
231 protected $silent = true; 222 protected $silent = true;
232 223
233 - private $salt = 'installers'; 224 + //protected $salt = 'installers';
234 225
235 /** 226 /**
236 * Main control of database setup 227 * Main control of database setup
@@ -284,7 +275,8 @@ class database extends Step @@ -284,7 +275,8 @@ class database extends Step
284 $this->setPostConfig(); // Set any posted variables 275 $this->setPostConfig(); // Set any posted variables
285 return 'next'; 276 return 'next';
286 } else if($this->edit()) { 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 $this->temp_variables['state'] = 'edit'; 280 $this->temp_variables['state'] = 'edit';
289 281
290 return 'landing'; 282 return 'landing';
@@ -363,8 +355,8 @@ class database extends Step @@ -363,8 +355,8 @@ class database extends Step
363 * @return boolean 355 * @return boolean
364 */ 356 */
365 private function setErrorsFromSession() { 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 return true; 361 return true;
370 } 362 }
@@ -382,7 +374,7 @@ class database extends Step @@ -382,7 +374,7 @@ class database extends Step
382 */ 374 */
383 public function setPostConfig() { 375 public function setPostConfig() {
384 $this->dtype = $this->getPostSafe("dtype"); 376 $this->dtype = $this->getPostSafe("dtype");
385 - $this->dtypes = array("0"=>"mysql"); // TODO:multiple databases 377 + $this->dtypes = array("0"=>"mysql");
386 $this->dhost = $this->getPostSafe("dhost"); 378 $this->dhost = $this->getPostSafe("dhost");
387 $this->dport = $this->getPostSafe("dport"); 379 $this->dport = $this->getPostSafe("dport");
388 $this->dname = $this->getPostSafe("dname"); 380 $this->dname = $this->getPostSafe("dname");
@@ -408,7 +400,7 @@ class database extends Step @@ -408,7 +400,7 @@ class database extends Step
408 public function loadDefaults($simplexml) { 400 public function loadDefaults($simplexml) {
409 if($simplexml) { 401 if($simplexml) {
410 $this->temp_variables['dtype'] = ""; 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 $this->temp_variables['dname'] = (string) $simplexml->dname; 404 $this->temp_variables['dname'] = (string) $simplexml->dname;
413 $this->temp_variables['duname'] = (string) $simplexml->duname; 405 $this->temp_variables['duname'] = (string) $simplexml->duname;
414 $this->temp_variables['dhost'] = (string) $simplexml->dhost; 406 $this->temp_variables['dhost'] = (string) $simplexml->dhost;
@@ -416,8 +408,8 @@ class database extends Step @@ -416,8 +408,8 @@ class database extends Step
416 $this->temp_variables['dpassword'] = ''; 408 $this->temp_variables['dpassword'] = '';
417 $this->temp_variables['dmsname'] = (string) $simplexml->dmsadminuser; 409 $this->temp_variables['dmsname'] = (string) $simplexml->dmsadminuser;
418 $this->temp_variables['dmsusername'] = (string) $simplexml->dmsuser; 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 if(WINDOWS_OS) { 413 if(WINDOWS_OS) {
422 $this->temp_variables['dbbinary'] = 'mysql.exe'; 414 $this->temp_variables['dbbinary'] = 'mysql.exe';
423 } else { 415 } else {
@@ -445,7 +437,7 @@ class database extends Step @@ -445,7 +437,7 @@ class database extends Step
445 $this->temp_variables['state'] = ''; 437 $this->temp_variables['state'] = '';
446 } 438 }
447 $this->temp_variables['dtype'] = $this->getPostSafe('dtype'); 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 $this->temp_variables['dhost'] = $this->getPostSafe('dhost'); 441 $this->temp_variables['dhost'] = $this->getPostSafe('dhost');
450 $this->temp_variables['dport'] = $this->getPostSafe('dport'); 442 $this->temp_variables['dport'] = $this->getPostSafe('dport');
451 $this->temp_variables['dname'] = $this->getPostSafe('dname'); 443 $this->temp_variables['dname'] = $this->getPostSafe('dname');
@@ -771,16 +763,34 @@ class database extends Step @@ -771,16 +763,34 @@ class database extends Step
771 $dbMigrate = $this->util->getDataFromPackage('migrate', 'database'); 763 $dbMigrate = $this->util->getDataFromPackage('migrate', 'database');
772 $sqlFile = $dbMigrate['dumpLocation']; 764 $sqlFile = $dbMigrate['dumpLocation'];
773 $this->parse_mysql_dump($sqlFile); 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 $this->addServerPort(); 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 $this->reBuildPaths(); 776 $this->reBuildPaths();
780 $this->writeBinaries(); // Rebuild some of the binaries 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 private function reBuildPaths() { 796 private function reBuildPaths() {
setup/wizard/templates/database.tpl
@@ -21,7 +21,6 @@ @@ -21,7 +21,6 @@
21 $input_size = '45'; 21 $input_size = '45';
22 $align = 'left'; 22 $align = 'left';
23 ?> 23 ?>
24 -<!-- TODO: Different Databases-->  
25 <?php if($state != 'edit') { ?> 24 <?php if($state != 'edit') { ?>
26 <tr><td>Your current database type is: </td> 25 <tr><td>Your current database type is: </td>
27 <?php if($dtypes) { 26 <?php if($dtypes) {
@@ -86,7 +85,6 @@ @@ -86,7 +85,6 @@
86 <input type="button" name="Next" value="Next" onclick="javascript:{w.showStep(1, 'n');}" class="button_next"/> 85 <input type="button" name="Next" value="Next" onclick="javascript:{w.showStep(1, 'n');}" class="button_next"/>
87 <?php } ?> 86 <?php } ?>
88 </div> 87 </div>
89 -  
90 <!-- STEP 2 of the database configuration - Admin user password settings --> 88 <!-- STEP 2 of the database configuration - Admin user password settings -->
91 <div id="database" class="step2" style="display:none;"> 89 <div id="database" class="step2" style="display:none;">
92 <div class="description"> 90 <div class="description">
@@ -114,7 +112,6 @@ An administrative user is required for creating tables within the database. @@ -114,7 +112,6 @@ An administrative user is required for creating tables within the database.
114 <input type="button" name="Previous" value="Previous" onclick="javascript:{w.showStep(2, 'p');}" class="button_previous"/> 112 <input type="button" name="Previous" value="Previous" onclick="javascript:{w.showStep(2, 'p');}" class="button_previous"/>
115 <input type="button" name="Next" value="Next" onclick="javascript:{w.showStep(2, 'n');}" class="button_next"/> 113 <input type="button" name="Next" value="Next" onclick="javascript:{w.showStep(2, 'n');}" class="button_next"/>
116 </div> 114 </div>
117 -  
118 <!-- STEP 3 of the database configuration - default user password settings --> 115 <!-- STEP 3 of the database configuration - default user password settings -->
119 <div id="database" class="step3" style="display:none;"> 116 <div id="database" class="step3" style="display:none;">
120 <div class="description"> 117 <div class="description">
setup/wizard/templates/database_confirm.tpl
1 <form id="services_database_registration" action="index.php?step_name=<?php echo $step_name; ?>" method="post"> 1 <form id="services_database_registration" action="index.php?step_name=<?php echo $step_name; ?>" method="post">
2 <p class="title">Confirming Database Configurations</p> 2 <p class="title">Confirming Database Configurations</p>
3 -  
4 <div class="description"> 3 <div class="description">
5 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> 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 </div> 5 </div>
@@ -41,9 +40,7 @@ @@ -41,9 +40,7 @@
41 </tr> 40 </tr>
42 <?php } ?> 41 <?php } ?>
43 </table> 42 </table>
44 - <!--</div>-->  
45 <h3><b>Advanced Settings</b></h3> 43 <h3><b>Advanced Settings</b></h3>
46 -  
47 <table class="dbconf"> 44 <table class="dbconf">
48 <tr> 45 <tr>
49 <td width="153px">Host: </td> 46 <td width="153px">Host: </td>
@@ -68,29 +65,23 @@ @@ -68,29 +65,23 @@
68 </tr> 65 </tr>
69 <?php } ?> 66 <?php } ?>
70 </table> 67 </table>
71 -  
72 <h3><b>Database Users (System Generated)</b></h3> 68 <h3><b>Database Users (System Generated)</b></h3>
73 -  
74 <table class="dbconf"> 69 <table class="dbconf">
75 - <?php //if (!$silent) { ?>  
76 <tr> 70 <tr>
77 <td width="153px">DMS Admin Username: </td> 71 <td width="153px">DMS Admin Username: </td>
78 <td width="15px"> <div id="tooltips" title="Database Administrative User for KnowledgeTree System">&nbsp;</div> </td> 72 <td width="15px"> <div id="tooltips" title="Database Administrative User for KnowledgeTree System">&nbsp;</div> </td>
79 <td><?php echo $dmsname; ?></td> 73 <td><?php echo $dmsname; ?></td>
80 </tr> 74 </tr>
81 - <?php //} ?>  
82 <tr> 75 <tr>
83 <td>DMS Admin Password: </td> 76 <td>DMS Admin Password: </td>
84 <td> <div id="tooltips" title="Database Administrative User password">&nbsp;</div> </td> 77 <td> <div id="tooltips" title="Database Administrative User password">&nbsp;</div> </td>
85 <td><?php echo $dmspassword; ?></td> 78 <td><?php echo $dmspassword; ?></td>
86 </tr> 79 </tr>
87 - <?php //if (!$silent) { ?>  
88 <tr> 80 <tr>
89 <td>DMS User Username: </td> 81 <td>DMS User Username: </td>
90 <td> <div id="tooltips" title="Database User for KnowledgeTree System">&nbsp;</div> </td> 82 <td> <div id="tooltips" title="Database User for KnowledgeTree System">&nbsp;</div> </td>
91 <td><?php echo $dmsusername; ?></td> 83 <td><?php echo $dmsusername; ?></td>
92 </tr> 84 </tr>
93 - <?php //} ?>  
94 <tr> 85 <tr>
95 <td>DMS User Password: </td> 86 <td>DMS User Password: </td>
96 <td> <div id="tooltips" title="Database User password">&nbsp;</div> </td> 87 <td> <div id="tooltips" title="Database User password">&nbsp;</div> </td>