public static function install() { session_destroy(); // // Create necessary dirs // if (!file_exists(CINTIENT_WORK_DIR) && !mkdir(CINTIENT_WORK_DIR, DEFAULT_DIR_MASK, true)) { SystemEvent::raise(SystemEvent::ERROR, "Could not create working dir. Check your permissions.", __METHOD__); echo "Error"; // TODO: treat this properly exit; } if (!file_exists(CINTIENT_PROJECTS_DIR) && !mkdir(CINTIENT_PROJECTS_DIR, DEFAULT_DIR_MASK, true)) { SystemEvent::raise(SystemEvent::ERROR, "Could not create projects dir. Check your permissions.", __METHOD__); echo "Error"; // TODO: treat this properly exit; } if (!file_exists(CINTIENT_ASSETS_DIR) && !mkdir(CINTIENT_ASSETS_DIR, DEFAULT_DIR_MASK, true)) { SystemEvent::raise(SystemEvent::ERROR, "Could not create assets dir. Check your permissions.", __METHOD__); echo "Error"; // TODO: treat this properly exit; } if (!file_exists(CINTIENT_AVATARS_DIR) && !mkdir(CINTIENT_AVATARS_DIR, DEFAULT_DIR_MASK, true)) { SystemEvent::raise(SystemEvent::ERROR, "Could not create avatars dir. Check your permissions.", __METHOD__); echo "Error"; // TODO: treat this properly exit; } // // Setup all objects // if (!User::install()) { SystemEvent::raise(SystemEvent::ERROR, "Could not setup User object.", __METHOD__); echo "Error"; // TODO: treat this properly exit; } if (!Project::install()) { SystemEvent::raise(SystemEvent::ERROR, "Could not setup Project object.", __METHOD__); echo "Error"; // TODO: treat this properly exit; } if (!SystemSettings::install()) { SystemEvent::raise(SystemEvent::ERROR, "Could not setup SystemSettings object.", __METHOD__); echo "Error"; // TODO: treat this properly exit; } // // Test user setup // $user = new User(); $user->setEmail('*****@*****.**'); $user->setNotificationEmails('pedro.matamouros@gmail.com,'); $user->setName('Pedro Mata-Mouros'); $user->setUsername('matamouros'); $user->setCos(UserCos::ROOT); $user->init(); $user->setPassword('pedro'); header('Location: ' . UrlManager::getForDashboard()); exit; }
if (!Database::endTransaction()) { Database::rollbackTransaction(); $ok = false; $msg = "Problems commiting all changes to the database."; SystemEvent::raise(CINTIENT_LOG_SEVERITY_ERROR, $msg, "Installer"); sendResponse($ok, $msg); } $settings = SystemSettings::load(); $settings->setSetting(SystemSettings::VERSION, CINTIENT_INSTALLER_VERSION); if (!$upgrade) { // // Root user account // $user = new User(); $user->setEmail($get['email']); $user->setNotificationEmails($get['email'] . ','); $user->setName('Administrative Account'); $user->setUsername('root'); $user->setCos(2); $user->init(); $user->setPassword($get['password']); } // Just to make sure everything's neat and tidy, especially after // an upgrade. Database::execute('VACUUM'); // // Last step: remove the installation file // if (!@unlink(__FILE__)) { $ok = false; $msg = "Couldn't remove the installation 'index.php' file. You need " . "to remove this manually before refreshing this page, or else" . " Cintient won't be able to start";