/** * Upgrade to the latest version. * * @param String $currentVersion Phprojekt version string indicating our * current version * @param Zend_Db_Adapter_Abstract $db The database to use * * @return void * @throws Exception On Errors */ public function upgrade($currentVersion, Zend_Db_Adapter_Abstract $db) { $this->_db = $db; if (is_null($currentVersion) || Phprojekt::compareVersion($currentVersion, '6.1.4') < 0) { $obj =& $this; $before = function ($oldVersion, $newVersion) use($obj) { $obj->beforeVersionStep($oldVersion, $newVersion); }; $after = function ($oldVersion, $newVersion) use($obj) { $obj->afterVersionStep($oldVersion, $newVersion); }; $dbParser = new Phprojekt_DbParser(array('useExtraData' => false), Phprojekt::getInstance()->getDb()); $dbParser->parseSingleModuleData('Project', null, array('before' => $before, 'after' => $after)); Phprojekt::getInstance()->getCache()->clean(Zend_Cache::CLEANING_MODE_ALL); } if (is_null($currentVersion) || Phprojekt::compareVersion($currentVersion, '6.2.1') < 0) { $this->repairUserRightsOnRoot(); $this->patchOldModuleGrids(); } }
/** * Helper function that parses the SQL/Db.json file and updates the database * accordingly. * * @param string $module The name of this module. * * @return void */ protected final function parseDbFile($module) { $dbParser = new Phprojekt_DbParser(array('useExtraData' => false), Phprojekt::getInstance()->getDb()); $dbParser->parseSingleModuleData($module); }
/** * Install all the tables and return the messages generated. * * @param array $params Array with options for the install. * * @return array Array with messages of what was installed. */ public function install($params) { $options = array(); $options['useExtraData'] = (bool) $params['useExtraData']; $db = $this->_getDb(); // Install tables $dbParser = new Phprojekt_DbParser($options, $db); $dbParser->parseData(PHPR_ROOT_PATH . DIRECTORY_SEPARATOR . 'application'); // Update users passwords $usersNamespace = new Zend_Session_Namespace('usersData'); // Update admin Pass $db->update('setting', array('value' => md5('phprojektmd5' . $usersNamespace->data['adminPass'])), 'id = 1'); // Update test Pass $db->update('setting', array('value' => md5('phprojektmd5' . $usersNamespace->data['testPass'])), 'user_id = 2 AND key_value = \'password\''); return $dbParser->getMessages(); }
/** * Install itself. * * @param array $params Array with the POST values. * * @return void */ public function install($params) { $options = array(); $options['useExtraData'] = (bool) $params['useExtraData']; $dbParser = new Phprojekt_DbParser($options, $this->_db); $dbParser->parseData(PHPR_ROOT_PATH . DIRECTORY_SEPARATOR . 'application'); // Update admin Pass $this->_db->update('setting', array('value' => md5('phprojektmd5' . $params['adminPass'])), 'id = 1'); // Update test Pass $this->_db->update('setting', array('value' => md5('phprojektmd5' . $params['testPass'])), 'user_id = 2 AND key_value = \'password\''); // Migration if (file_exists($params['migrationConfigFile'])) { try { $migration = new Setup_Models_Migration($params['migrationConfigFile'], $params['diffToUtc'], $this->_db); $migration->migrateTables(); } catch (Exception $error) { echo $error->getMessage(); } } // Create config file $config = new Setup_Models_Config(); $content = $config->getDefaultProduction($params['dbUser'], $params['dbPass'], $params['dbName'], 'Pdo_Mysql', $params['dbHost']); $baseDir = str_replace('htdocs/setup.php', '', $_SERVER['SCRIPT_FILENAME']); $configFile = $baseDir . "configuration.ini"; file_put_contents($configFile, $content); // Delete a session if exists $_SESSION = array(); foreach ($_COOKIE as $key => $value) { setcookie($key, "", 1); } Zend_Session::writeClose(); }