From 1f4fb4ccb5846f16fd46a6179023cfcc9854d9d0 Mon Sep 17 00:00:00 2001 From: Jarrett Jordaan Date: Mon, 1 Mar 2010 09:47:13 +0200 Subject: [PATCH] PT:2492070 : First Login wizard updated --- dashboard.php | 12 ++++++++++++ setup/firstlogin/firstlogin.php | 26 +++++++++++++++++++++++++- setup/firstlogin/firstloginUtil.php | 40 ++++++++-------------------------------- setup/firstlogin/firstloginWizard.php | 2 +- setup/firstlogin/step.php | 18 +++++++++++++++++- setup/firstlogin/steps/firstloginComplete.php | 2 +- setup/firstlogin/steps/firstloginTemplates.php | 6 ++++-- setup/firstlogin/templates/complete.tpl | 5 ++++- setup/firstlogin/templates/templates.tpl | 15 +++++++++------ setup/wizard/installer.php | 1 + setup/wizard/resources/js/firstlogin.js | 34 ++++++++++++++++++++++++++++------ setup/wizard/steps/complete.php | 9 --------- 12 files changed, 110 insertions(+), 60 deletions(-) diff --git a/dashboard.php b/dashboard.php index 346ebc1..c097420 100644 --- a/dashboard.php +++ b/dashboard.php @@ -135,9 +135,21 @@ class DashboardDispatcher extends KTStandardDispatcher { 'dashlets_left' => $aDashletsLeft, 'dashlets_right' => $aDashletsRight, ); + + // TODO : Is this ok? + if(file_exists(KT_DIR.DIRECTORY_SEPARATOR.'var'.DIRECTORY_SEPARATOR.'bin'.DIRECTORY_SEPARATOR."firstlogin.lock")) { + $this->runFirstLoginWizard($oTemplate, $aTemplateData); + } + return $oTemplate->render($aTemplateData); } + // + function runFirstLoginWizard($oTemplate, $aTemplateData) { + $this->oPage->requireJSResource('thirdpartyjs/jquery/jquery-1.3.2.min.js'); + $this->oPage->requireJSResource('setup/wizard/resources/js/firstlogin.js'); + } + // return some kind of ID for each dashlet // currently uses the class name function _getDashletId($oDashlet) { diff --git a/setup/firstlogin/firstlogin.php b/setup/firstlogin/firstlogin.php index c84393f..0b73dc9 100644 --- a/setup/firstlogin/firstlogin.php +++ b/setup/firstlogin/firstlogin.php @@ -491,7 +491,8 @@ class firstlogin { $this->_readXml(); // Xml steps $this->_resetSessions(); // Make sure session is cleared $this->_loadFromSessions(); - if(isset($_POST['Next'])) { $this->action = 'next'; + if(isset($_POST['Next'])) { + $this->action = 'next'; $this->response = 'next'; } elseif (isset($_POST['Previous'])) { $this->action = 'previous'; @@ -509,8 +510,31 @@ class firstlogin { $this->response = ''; $this->action = ''; } + $this->loadAjax(); } + private function loadAjax() { + if(isset($_GET['Next'])) { + $this->action = 'next'; + $this->response = 'next'; + } elseif (isset($_GET['Previous'])) { + $this->action = 'previous'; + $this->response = 'previous'; + } elseif (isset($_GET['Confirm'])) { + $this->action = 'confirm'; + $this->response = 'next'; + } elseif (isset($_GET['Edit'])) { + $this->action = 'edit'; + $this->response = 'next'; + } elseif (isset($_GET['Skip'])) { + $this->action = 'next'; + $this->response = 'next'; + } else { + $this->response = ''; + $this->action = ''; + } + } + /** * Main control to handle the flow * diff --git a/setup/firstlogin/firstloginUtil.php b/setup/firstlogin/firstloginUtil.php index a64da5d..8b30ac2 100644 --- a/setup/firstlogin/firstloginUtil.php +++ b/setup/firstlogin/firstloginUtil.php @@ -85,47 +85,23 @@ class firstloginUtil extends InstallUtil { * @return mixed */ public function checkStructurePermissions() { - // Check if Wizard Directory is writable - if(!$this->_checkPermission(WIZARD_DIR)) { + if(!$this->_checkPermission(WIZARD_DIR)) { // Check if Wizard Directory is writable return 'firstlogin'; } return true; } - public function loadInstallServices() { - require_once("../wizard/steps/services.php"); - $s = new services(); - return $s->getServices(); - } - - public function loadInstallService($serviceName) { - require_once("../wizard/lib/services/service.php"); - require_once("../wizard/lib/services/".OS."Service.php"); - require_once("../wizard/lib/services/$serviceName.php"); - return new $serviceName(); - } - /** - * Return port of the old installation + * Deletes first login lock file * - * @param location - * @return string + * @author KnowledgeTree Team + * @access public + * @return void */ - public function getPort($location) { - if(WINDOWS_OS) { - $myIni = "my.ini"; - } else { - $myIni = "my.cnf"; - } - $dbConfigPath = $location.DS."mysql".DS."$myIni"; - if(file_exists($dbConfigPath)) { - $this->iniUtilities->load($dbConfigPath); - $dbSettings = $this->iniUtilities->getSection('mysqladmin'); - return $dbSettings['port']; - } - - return '3306'; + public function deleteFirstLogin() { + if(file_exists(SYSTEM_DIR.'var'.DS.'bin'.DS."firstlogin.lock")) + unlink(SYSTEM_DIR.'var'.DS.'bin'.DS."firstlogin.lock"); } } ?> \ No newline at end of file diff --git a/setup/firstlogin/firstloginWizard.php b/setup/firstlogin/firstloginWizard.php index 186ffdd..a170336 100644 --- a/setup/firstlogin/firstloginWizard.php +++ b/setup/firstlogin/firstloginWizard.php @@ -165,7 +165,7 @@ class firstloginWizard extends WizardBase { } elseif ($this->getBypass() === "0") { $this->createFile(); } - if(!$this->isFirstLogin()) { // Check if the systems + if($this->isFirstLogin()) { // Check if the systems $response = $this->systemChecks(); if($response === true) { $this->display(); diff --git a/setup/firstlogin/step.php b/setup/firstlogin/step.php index 4b90c1a..827690e 100644 --- a/setup/firstlogin/step.php +++ b/setup/firstlogin/step.php @@ -145,7 +145,23 @@ class Step extends StepBase */ public function run() { return $this->run; - } + } + + /** + * Checks if next button has been clicked + * + * @author KnowledgeTree Team + * @param none + * @access public + * @return boolean + */ + public function next() { + if(isset($_GET['Next'])) { + return true; + } + + return false; + } } ?> \ No newline at end of file diff --git a/setup/firstlogin/steps/firstloginComplete.php b/setup/firstlogin/steps/firstloginComplete.php index d58aa14..e6bf350 100644 --- a/setup/firstlogin/steps/firstloginComplete.php +++ b/setup/firstlogin/steps/firstloginComplete.php @@ -68,7 +68,7 @@ class firstloginComplete extends Step { } function doRun() { - + $this->util->deleteFirstLogin(); return 'landing'; } diff --git a/setup/firstlogin/steps/firstloginTemplates.php b/setup/firstlogin/steps/firstloginTemplates.php index 6020c32..d003bff 100644 --- a/setup/firstlogin/steps/firstloginTemplates.php +++ b/setup/firstlogin/steps/firstloginTemplates.php @@ -91,14 +91,16 @@ class firstloginTemplates extends Step { function applyTemplates() { $templateId = KTUtil::arrayGet($_POST['data'], "templateId", 0); + if($templateId < 1) { + $templateId = KTUtil::arrayGet($_GET, "templateId", 0);// Could be ajax call + } if($templateId > 0) { if (KTPluginUtil::pluginIsActive('fs.FolderTemplatesPlugin.plugin')) { // Check if folder templates plugin is active $oRegistry =& KTPluginRegistry::getSingleton(); $oPlugin =& $oRegistry->getPlugin('fs.FolderTemplatesPlugin.plugin'); // Get a handle on the plugin - return $oPlugin->applyFolderTemplate($templateId, 1); + return $oPlugin->firstLoginAction(1, $templateId); } } - return false; } diff --git a/setup/firstlogin/templates/complete.tpl b/setup/firstlogin/templates/complete.tpl index d5cb001..e133376 100644 --- a/setup/firstlogin/templates/complete.tpl +++ b/setup/firstlogin/templates/complete.tpl @@ -6,6 +6,9 @@ js('form.js'); } ?> \ No newline at end of file diff --git a/setup/firstlogin/templates/templates.tpl b/setup/firstlogin/templates/templates.tpl index 35c7d84..51e5b90 100644 --- a/setup/firstlogin/templates/templates.tpl +++ b/setup/firstlogin/templates/templates.tpl @@ -1,12 +1,12 @@ -
+

Apply Templates

You can select a base folder layout to apply to your root folder of KnowledgeTree.

Choose a template, if you would like to generate predefined folders.

- + getId()}')}\" value=\"{$oFolderTemplate->getId()}\">".$oFolderTemplate->getName().""; @@ -45,10 +45,13 @@
- - + +
js('form.js'); } ?> \ No newline at end of file diff --git a/setup/wizard/installer.php b/setup/wizard/installer.php index cf72d9d..0e46b07 100644 --- a/setup/wizard/installer.php +++ b/setup/wizard/installer.php @@ -142,6 +142,7 @@ class Installer extends NavBase { */ private function completeInstall() { touch(SYSTEM_DIR.'var'.DS.'bin'.DS."install.lock"); + touch(SYSTEM_DIR.'var'.DS.'bin'.DS."firstlogin.lock"); } /** diff --git a/setup/wizard/resources/js/firstlogin.js b/setup/wizard/resources/js/firstlogin.js index 5372261..3313750 100644 --- a/setup/wizard/resources/js/firstlogin.js +++ b/setup/wizard/resources/js/firstlogin.js @@ -1,14 +1,14 @@ -// Class First Login -//TODO : Plugin path in js -var ktfolderAccess = "../../plugins/commercial/folder-templates/KTFolderTemplates.php?action="; -var ktmanageFolderAccess = "admin.php?kt_path_info=misc/adminfoldertemplatesmanagement&action="; +var win; + $(function() { // Document is ready if($("#wrapper").attr('class') != 'wizard') {// Check if we in a wizard, or on the dashboard showForm(); // Display first login wizard } }); +// Class First Login function firstlogin(rootUrl) { + this.rootUrl = rootUrl; this.ktfolderAccess = rootUrl + "plugins/commercial/folder-templates/KTFolderTemplates.php?action="; this.ktmanageFolderAccess = rootUrl + "admin.php?kt_path_info=misc/adminfoldertemplatesmanagement&action="; this.ajaxOn = false; @@ -49,6 +49,7 @@ firstlogin.prototype.hideFolderTemplateTrees = function() { ); } +// Template has this action. Not needed in first login wizard firstlogin.prototype.showNodeOptions = function() { } @@ -68,13 +69,12 @@ var showForm = function() { shadow: false, modal: true }); - this.win.show(); } var createForm = function() { var holder = "
"; - $("#wrapper").append(holder); // Append to current dashboard + $("#pageBody").append(holder); // Append to current dashboard var address = "setup/firstlogin/index.php"; getUrl(address, "firstlogin"); // Pull in existing wizard } @@ -93,6 +93,19 @@ var getUrl = function (address, div) { }); } +/* +* Close the popup +*/ +var closeFirstLogin = function () { + this.win.destroy(); + $('.ext-el-mask').each( // TODO : Why does overlay hang around? + function() { + $(this).remove(); + } + ); + +} + // Node clicked firstlogin.prototype.nodeAction = function(updateContentDiv, updateDiv, address) { var className = $("#"+updateDiv).attr('class'); @@ -106,4 +119,13 @@ firstlogin.prototype.nodeAction = function(updateContentDiv, updateDiv, address) } } +firstlogin.prototype.getRootUrl = function() { + return this.rootUrl; +} +firstlogin.prototype.sendFirstLoginForm = function() { + var templateId = $("#selectedTemplate").val(); + var action = $("#step_name_templates").attr('action'); + var address = this.rootUrl + "setup/firstlogin/" + action + "&templateId=" + templateId + "&Next=Next"; + getUrl(address, 'firstlogin'); +} diff --git a/setup/wizard/steps/complete.php b/setup/wizard/steps/complete.php index 847b8a4..bc370f7 100644 --- a/setup/wizard/steps/complete.php +++ b/setup/wizard/steps/complete.php @@ -242,21 +242,12 @@ class complete extends Step { function checkInstallType() { if ($this->util->isMigration()) { $this->migrate_check = true; - $this->registerPlugins(); // Set silent mode variables } else { $this->migrate_check = false; } } /** - * Register extra commercial plugins - * - */ - private function registerPlugins() { - - } - - /** * Set all silent mode varibles * */ -- libgit2 0.21.4